Skip to content

Commit

Permalink
Close #789 update ticket template link base on product type
Browse files Browse the repository at this point in the history
  • Loading branch information
kimsrung committed Nov 6, 2023
1 parent f7fd542 commit eb1531f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
25 changes: 25 additions & 0 deletions app/helpers/spree/base_helper_decorator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module Spree
module BaseHelperDecorator
def custom_product_storefront_resource_url(resource, options = {})
if defined?(locale_param) && locale_param.present?
options.merge!(locale: locale_param)
end

localize = if options[:locale].present?
"/#{options[:locale]}"
else
''
end

if resource.product_type == 'accommodation'
"#{current_store.formatted_url + localize}/rooms/#{resource.slug}"
elsif resource.product_type == 'ecommerce'
"#{current_store.formatted_url + localize}/tickets/#{resource.slug}"
else
spree_storefront_resource_url(resource)
end
end
end
end

Spree::BaseHelper.prepend(Spree::BaseHelperDecorator)
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<% line_items.each do |line_item| %>
<tr>
<td class="purchase_image">
<%= link_to(image_tag(variant_image_url(line_item.variant)), spree_storefront_resource_url(line_item.product)) %>
<%= link_to(image_tag(variant_image_url(line_item.variant)), custom_product_storefront_resource_url(line_item.product)) %>
</td>
<td class="purchase_item">
<p><%= link_to raw(line_item.name), spree_storefront_resource_url(line_item.product) %></p>
<p><%= link_to raw(line_item.name), custom_product_storefront_resource_url(line_item.product) %></p>
<p><%= line_item.variant.options_text %></p>
</td>
<td class="align-right" width="10%">
Expand Down

0 comments on commit eb1531f

Please sign in to comment.