spree_storefront 5.2.5 → 5.3.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +5 -3
  3. data/app/controllers/concerns/spree/cart_methods.rb +4 -3
  4. data/app/controllers/concerns/spree/storefront/pagination_concern.rb +23 -0
  5. data/app/controllers/spree/account/gift_cards_controller.rb +1 -1
  6. data/app/controllers/spree/account/orders_controller.rb +2 -2
  7. data/app/controllers/spree/account/store_credits_controller.rb +4 -4
  8. data/app/controllers/spree/addresses_controller.rb +2 -2
  9. data/app/controllers/spree/checkout_controller.rb +14 -8
  10. data/app/controllers/spree/line_items_controller.rb +3 -3
  11. data/app/controllers/spree/order_status_controller.rb +1 -1
  12. data/app/controllers/spree/orders_controller.rb +3 -3
  13. data/app/controllers/spree/posts_controller.rb +1 -1
  14. data/app/controllers/spree/products_controller.rb +1 -0
  15. data/app/controllers/spree/search_controller.rb +1 -1
  16. data/app/controllers/spree/store_controller.rb +28 -33
  17. data/app/helpers/spree/canonical_url_helper.rb +27 -0
  18. data/app/helpers/spree/checkout_analytics_helper.rb +1 -4
  19. data/app/helpers/spree/checkout_helper.rb +3 -1
  20. data/app/helpers/spree/page_helper.rb +2 -4
  21. data/app/helpers/spree/products_helper.rb +31 -8
  22. data/app/helpers/spree/storefront_helper.rb +2 -1
  23. data/app/helpers/spree/taxons_helper.rb +3 -1
  24. data/app/helpers/spree/theme_helper.rb +1 -1
  25. data/app/views/devise/sessions/new.html.erb +1 -1
  26. data/app/views/spree/checkout/_address.html.erb +2 -2
  27. data/app/views/spree/checkout/_coupon_code.html.erb +2 -2
  28. data/app/views/spree/checkout/_delivery.html.erb +2 -2
  29. data/app/views/spree/checkout/_delivery_shipping_rate.html.erb +1 -1
  30. data/app/views/spree/checkout/_line_items.html.erb +3 -5
  31. data/app/views/spree/checkout/_payment_methods.html.erb +1 -1
  32. data/app/views/spree/products/index.html.erb +1 -1
  33. data/app/views/spree/search/show.html.erb +1 -1
  34. data/app/views/spree/shared/_load_more_products.turbo_stream.erb +1 -1
  35. data/app/views/spree/shared/_product_listing_page.html.erb +2 -2
  36. data/app/views/themes/default/spree/page_sections/_featured_product.html.erb +4 -4
  37. data/app/views/themes/default/spree/page_sections/_featured_taxons.html.erb +4 -4
  38. data/app/views/themes/default/spree/page_sections/_footer.html.erb +6 -6
  39. data/app/views/themes/default/spree/page_sections/_header.html.erb +5 -2
  40. data/app/views/themes/default/spree/page_sections/_post_grid.html.erb +1 -1
  41. data/app/views/themes/default/spree/page_sections/_product_details.html.erb +2 -2
  42. data/app/views/themes/default/spree/posts/_pagination.html.erb +1 -1
  43. data/app/views/themes/default/spree/products/_add_to_cart_button.html.erb +16 -3
  44. data/app/views/themes/default/spree/products/_color_swatches.html.erb +1 -1
  45. data/app/views/themes/default/spree/products/_featured_image.html.erb +2 -1
  46. data/app/views/themes/default/spree/products/_json_ld.html.erb +4 -4
  47. data/app/views/themes/default/spree/products/_price.html.erb +3 -1
  48. data/app/views/themes/default/spree/products/_product.html.erb +3 -3
  49. data/app/views/themes/default/spree/products/_quantity_selector.html.erb +6 -4
  50. data/app/views/themes/default/spree/products/_show_more_button.html.erb +3 -3
  51. data/app/views/themes/default/spree/products/_swiper.html.erb +2 -2
  52. data/app/views/themes/default/spree/products/_variant_options.html.erb +6 -2
  53. data/app/views/themes/default/spree/products/_variant_picker.html.erb +5 -3
  54. data/app/views/themes/default/spree/shared/_custom_head.html.erb +7 -0
  55. data/app/views/themes/default/spree/shared/_line_item_options.html.erb +1 -1
  56. data/app/views/themes/default/spree/shared/_pagination.html.erb +7 -0
  57. data/app/views/themes/default/spree/shared/_search.html.erb +1 -1
  58. data/config/locales/en.yml +2 -0
  59. data/lib/generators/spree/storefront/install/install_generator.rb +12 -4
  60. data/lib/generators/spree/storefront/install/templates/application.css +45 -4
  61. data/lib/spree/storefront/configuration.rb +3 -0
  62. data/lib/spree/storefront.rb +3 -2
  63. metadata +33 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc8589dcfb75063c9c8730ad1f2f0912b4b167faf52bb7ddf2b6483967d8c66e
4
- data.tar.gz: 23134df31cfed598ed91bcec9501b9c3c019b4bd73c3ddf5ea7579e9e2043215
3
+ metadata.gz: 2d2469dfa268f4b5001def6a8efc6c6c69ee8e1cfcbec059f09b1b369f99f003
4
+ data.tar.gz: cbf4c3c04197c8c9b283efc23e04fe886b035159603e40ef36a30eb05a260252
5
5
  SHA512:
6
- metadata.gz: 1e94f62c94ff8d7ae85c11ac84753a40ba2d523fc83087b7db3eb9bf0bcc2606e789f39b5d681c6baee4729785d6d67e693bdfef45c7c54fe967634ea02ef993
7
- data.tar.gz: f24717be8ef70ae6414fc76dd1c7acc7cdfe705a303966a71a14be3549e7d42e5a3ece3fc3925a29cfb3e7f5b65cba9793d83c1be894af45d6694153eb9df75a
6
+ metadata.gz: 1bc5443c86a416f3d3145f5da3e5c19581c0e1955ca66dddfe680a9a3f81cf60b412acc5fb43dcc8af1e51b11e4ea1bb499cd1c6ba7347f22c4d577c56aed667
7
+ data.tar.gz: 78cc85fcae54894e3df300517534ee7163df515eb1cc76ac6ddab2de2a45ea0049ad903b20890da119d6605c1488e4b3e540eabf6d696445ba4c37c6d61001d9
data/Rakefile CHANGED
@@ -13,9 +13,11 @@ task :test_app do
13
13
  ENV['LIB_NAME'] = 'spree/storefront'
14
14
 
15
15
  Rake::Task['common:test_app'].execute(
16
- user_class: 'User',
16
+ user_class: 'Spree::User',
17
+ admin_user_class: 'Spree::AdminUser',
17
18
  authentication: 'devise',
18
- install_storefront: 'true',
19
- install_admin: 'false'
19
+ install_admin: true,
20
+ css: true,
21
+ javascript: true
20
22
  )
21
23
  end
@@ -39,12 +39,13 @@ module Spree
39
39
  {
40
40
  variant: [
41
41
  :images,
42
+ :prices,
43
+ { stock_items: :stock_location },
42
44
  { option_values: [:option_type] },
43
45
  {
44
46
  product: [
45
- :variants,
46
- :variant_images,
47
- { master: :images }
47
+ { master: :images },
48
+ { variants: :images }
48
49
  ]
49
50
  }
50
51
  ]
@@ -0,0 +1,23 @@
1
+ module Spree
2
+ module Storefront
3
+ module PaginationConcern
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ include Pagy::Method
8
+ end
9
+
10
+ private
11
+
12
+ def paginate_collection(collection, limit:)
13
+ if Spree::Storefront::Config[:use_kaminari_pagination]
14
+ collection.page(params[:page]).per(limit)
15
+ else
16
+ # Uses countish paginator which is faster as it avoids COUNT queries
17
+ @pagy, records = pagy(:countish, collection, limit: limit)
18
+ records
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -2,7 +2,7 @@ module Spree
2
2
  module Account
3
3
  class GiftCardsController < BaseController
4
4
  def index
5
- @gift_cards = @user.gift_cards.order(created_at: :desc).page(params[:page]).per(25)
5
+ @gift_cards = paginate_collection(@user.gift_cards.order(created_at: :desc), limit: 25)
6
6
  end
7
7
 
8
8
  private
@@ -5,7 +5,7 @@ module Spree
5
5
 
6
6
  # GET /account/orders
7
7
  def index
8
- @orders = orders_scope.order(created_at: :desc).page(params[:page]).per(25)
8
+ @orders = paginate_collection(orders_scope.order(created_at: :desc), limit: 25)
9
9
  end
10
10
 
11
11
  # GET /account/orders/:id
@@ -26,7 +26,7 @@ module Spree
26
26
  end
27
27
 
28
28
  def order_finder
29
- Spree::Dependencies.completed_order_finder.constantize
29
+ Spree.completed_order_finder
30
30
  end
31
31
 
32
32
  def load_order_details
@@ -3,10 +3,10 @@ module Spree
3
3
  class StoreCreditsController < BaseController
4
4
  # GET /account/store_credits
5
5
  def index
6
- @store_credit_events = Spree::StoreCreditEvent.where(store_credit: user_store_credits).
7
- exposed_events.
8
- reverse_chronological.
9
- page(params[:page]).per(25)
6
+ events = Spree::StoreCreditEvent.where(store_credit: user_store_credits).
7
+ exposed_events.
8
+ reverse_chronological
9
+ @store_credit_events = paginate_collection(events, limit: 25)
10
10
  end
11
11
 
12
12
  private
@@ -92,11 +92,11 @@ module Spree
92
92
  end
93
93
 
94
94
  def create_service
95
- Spree::Dependencies.address_create_service.constantize
95
+ Spree.address_create_service
96
96
  end
97
97
 
98
98
  def update_service
99
- Spree::Dependencies.address_update_service.constantize
99
+ Spree.address_update_service
100
100
  end
101
101
 
102
102
  def load_and_authorize_address
@@ -196,8 +196,14 @@ module Spree
196
196
 
197
197
  # completed orders shouldn't be updated anymore
198
198
  unless @order.completed?
199
- @order.assign_attributes(order_tracking_params)
200
- @order.update_columns(order_tracking_params)
199
+ tracking_params = order_tracking_params
200
+ changed_params = tracking_params.reject { |key, value| @order.public_send(key) == value }
201
+
202
+ if changed_params.any?
203
+ @order.assign_attributes(changed_params)
204
+ @order.update_columns(changed_params)
205
+ end
206
+
201
207
  @order.associate_user!(try_spree_current_user) if try_spree_current_user && @order.user.nil?
202
208
  end
203
209
  @current_order = @order # for compatibility with the rest of storefront, analytics, etc
@@ -342,7 +348,7 @@ module Spree
342
348
  packages = @order.shipments.map(&:to_package)
343
349
  @differentiator = Spree::Stock::Differentiator.new(@order, packages)
344
350
  @differentiator.missing.each do |variant, quantity|
345
- Spree::Dependencies.cart_remove_item_service.constantize.call(order: @order, variant: variant, quantity: quantity)
351
+ Spree.cart_remove_item_service.call(order: @order, variant: variant, quantity: quantity)
346
352
  end
347
353
  end
348
354
  end
@@ -365,19 +371,19 @@ module Spree
365
371
  end
366
372
 
367
373
  def add_store_credit_service
368
- Spree::Dependencies.checkout_add_store_credit_service.constantize
374
+ Spree.checkout_add_store_credit_service
369
375
  end
370
376
 
371
377
  def remove_store_credit_service
372
- Spree::Dependencies.checkout_remove_store_credit_service.constantize
378
+ Spree.checkout_remove_store_credit_service
373
379
  end
374
380
 
375
381
  def remove_line_item_service
376
- Spree::Dependencies.cart_remove_line_item_service.constantize
382
+ Spree.cart_remove_line_item_service
377
383
  end
378
384
 
379
385
  def coupon_handler
380
- Spree::Dependencies.coupon_handler.constantize
386
+ Spree.coupon_handler
381
387
  end
382
388
 
383
389
  def accurate_title
@@ -387,7 +393,7 @@ module Spree
387
393
  def remove_expired_gift_card
388
394
  return unless @order.gift_card.present? && @order.gift_card.expired?
389
395
 
390
- Spree::Dependencies.gift_card_remove_service.constantize.call(order: @order)
396
+ Spree.gift_card_remove_service.call(order: @order)
391
397
  end
392
398
  end
393
399
  end
@@ -89,15 +89,15 @@ module Spree
89
89
  end
90
90
 
91
91
  def cart_add_item_service
92
- Spree::Dependencies.cart_add_item_service.constantize
92
+ Spree.cart_add_item_service
93
93
  end
94
94
 
95
95
  def cart_remove_line_item_service
96
- Spree::Dependencies.cart_remove_line_item_service.constantize
96
+ Spree.cart_remove_line_item_service
97
97
  end
98
98
 
99
99
  def cart_set_item_quantity_service
100
- Spree::Dependencies.cart_set_item_quantity_service.constantize
100
+ Spree.cart_set_item_quantity_service
101
101
  end
102
102
  end
103
103
  end
@@ -26,7 +26,7 @@ module Spree
26
26
  end
27
27
 
28
28
  def order_finder
29
- Spree::Dependencies.completed_order_finder.constantize
29
+ Spree.completed_order_finder
30
30
  end
31
31
  end
32
32
  end
@@ -81,15 +81,15 @@ module Spree
81
81
  end
82
82
 
83
83
  def cart_remove_out_of_stock_items_service
84
- Spree::Dependencies.cart_remove_out_of_stock_items_service.constantize
84
+ Spree.cart_remove_out_of_stock_items_service
85
85
  end
86
86
 
87
87
  def cart_update_service
88
- Spree::Dependencies.cart_update_service.constantize
88
+ Spree.cart_update_service
89
89
  end
90
90
 
91
91
  def complete_order_finder
92
- Spree::Dependencies.completed_order_finder.constantize
92
+ Spree.completed_order_finder
93
93
  end
94
94
 
95
95
  def remove_out_of_stock_items
@@ -13,7 +13,7 @@ module Spree
13
13
  scope = scope.where(post_category_id: @category.id) if @category.present?
14
14
 
15
15
  sorted_posts = scope.order(published_at: :desc)
16
- @posts = sorted_posts.page(params[:page]).per(20)
16
+ @posts = paginate_collection(sorted_posts, limit: 20)
17
17
  end
18
18
 
19
19
  def show
@@ -25,6 +25,7 @@ module Spree
25
25
  # when using not default locale, our related products are different for different locales.
26
26
  @products = storefront_products_scope.where.not(id: @product.id).
27
27
  multi_search(@product.name).includes(storefront_products_includes).
28
+ preload_associations_lazily.
28
29
  limit(@section.preferred_max_products_to_show)
29
30
  end
30
31
 
@@ -14,7 +14,7 @@ module Spree
14
14
 
15
15
  if query.present? && query.length >= Spree::Storefront::Config.search_min_query_length
16
16
  products_scope = storefront_products_scope.multi_search(query)
17
- @products = products_scope.includes(storefront_products_includes)
17
+ @products = products_scope.includes(storefront_products_includes).preload_associations_lazily
18
18
  @taxons = current_store.taxons.search_by_name(query)
19
19
  end
20
20
  end
@@ -9,12 +9,14 @@ module Spree
9
9
  include Spree::WishlistHelper
10
10
  include Spree::AnalyticsHelper
11
11
  include Spree::IntegrationsHelper
12
+ include Spree::Storefront::PaginationConcern
12
13
 
13
14
  layout :choose_layout
14
15
 
15
16
  helper 'spree/base'
16
17
  helper 'spree/locale'
17
18
  helper 'spree/storefront_locale'
19
+ helper 'spree/canonical_url'
18
20
  helper 'spree/currency'
19
21
  helper 'spree/addresses'
20
22
  helper 'spree/wishlist'
@@ -27,7 +29,7 @@ module Spree
27
29
  helper_method :current_taxon, :store_filter_names
28
30
 
29
31
  helper_method :permitted_products_params, :products_filters_params,
30
- :storefront_products_scope, :storefront_products,
32
+ :storefront_products_scope, :storefront_products, :storefront_pagy,
31
33
  :default_products_sort, :default_products_finder_params,
32
34
  :storefront_products_includes, :storefront_products_finder
33
35
 
@@ -124,7 +126,7 @@ module Spree
124
126
  end
125
127
 
126
128
  def storefront_products_finder
127
- @storefront_products_finder ||= Spree::Dependencies.products_finder.constantize
129
+ @storefront_products_finder ||= Spree.products_finder
128
130
  end
129
131
 
130
132
  def storefront_products_scope
@@ -156,38 +158,36 @@ module Spree
156
158
  end
157
159
 
158
160
  def storefront_products
159
- @storefront_products ||= begin
160
- finder_params = default_products_finder_params
161
- finder_params[:sort_by] ||= @taxon&.sort_order || 'manual'
161
+ return @storefront_products if @storefront_products
162
162
 
163
- products_finder = storefront_products_finder
164
- products = products_finder.
165
- new(scope: storefront_products_scope, params: finder_params).
166
- execute.
167
- includes(storefront_products_includes)
163
+ finder_params = default_products_finder_params
164
+ finder_params[:sort_by] ||= @taxon&.sort_order || 'manual'
168
165
 
169
- default_per_page = Spree::Storefront::Config[:products_per_page]
170
- per_page = params[:per_page].present? ? params[:per_page].to_i : default_per_page
171
- page = params[:page].present? ? params[:page].to_i : 1
166
+ products_finder = storefront_products_finder
167
+ products = products_finder.
168
+ new(scope: storefront_products_scope, params: finder_params).
169
+ execute.
170
+ includes(storefront_products_includes).
171
+ preload_associations_lazily
172
172
 
173
- products.page(page).per(per_page)
174
- end
173
+ default_per_page = Spree::Storefront::Config[:products_per_page]
174
+ per_page = params[:per_page].present? ? params[:per_page].to_i : default_per_page
175
+
176
+ @storefront_products = paginate_collection(products, limit: per_page)
177
+ end
178
+
179
+ def storefront_pagy
180
+ storefront_products unless @storefront_products
181
+ @pagy
175
182
  end
176
183
 
184
+ # These includes are not picked automatically by ar_lazy_preload gem so we need to specify them manually.
177
185
  def storefront_products_includes
178
- [
179
- :prices_including_master,
180
- :variant_images,
181
- :option_types,
182
- :option_values,
183
- { master: [:images, :prices, :stock_items, :stock_locations, { stock_items: :stock_location }],
184
- variants: [
185
- :images, :prices, :option_values, :stock_items, :stock_locations,
186
- { option_values: :option_type, stock_items: :stock_location }
187
- ],
188
- taxons: [:taxonomy],
189
- taggings: [:tag] }
190
- ]
186
+ {
187
+ taxons: [],
188
+ master: [:images, :prices, { stock_items: :stock_location }],
189
+ variants: [:images, :prices, { stock_items: :stock_location }]
190
+ }
191
191
  end
192
192
 
193
193
  def redirect_unauthorized_access
@@ -204,11 +204,6 @@ module Spree
204
204
  end
205
205
  end
206
206
 
207
- def redirect_back_or_default(default)
208
- Spree::Deprecation.warn('redirect_back_or_default is deprecated and will be removed in Spree 5.2. Please use redirect_back(fallback_location: default) instead.')
209
- redirect_back(fallback_location: default)
210
- end
211
-
212
207
  def require_user(return_to: nil, redirect_path: nil)
213
208
  return if try_spree_current_user
214
209
 
@@ -0,0 +1,27 @@
1
+ module Spree
2
+ module CanonicalUrlHelper
3
+ # Generates a canonical link tag for the current page
4
+ #
5
+ # @param host [String] The host/domain to use (defaults to current store's domain)
6
+ # @return [ActiveSupport::SafeBuffer] The canonical link tag HTML
7
+ def canonical_tag(host = nil)
8
+ tag.link(href: canonical_href(host), rel: :canonical)
9
+ end
10
+
11
+ # Returns the full canonical URL for the current request
12
+ #
13
+ # @param host [String] The host/domain to use (defaults to request host)
14
+ # @return [String] The full canonical URL
15
+ def canonical_href(host = nil)
16
+ host ||= request.host
17
+ "#{request.protocol}#{host}#{canonical_path}"
18
+ end
19
+
20
+ # Returns the canonical path for the current request (without query parameters)
21
+ #
22
+ # @return [String] The canonical path
23
+ def canonical_path
24
+ request.path.presence || '/'
25
+ end
26
+ end
27
+ end
@@ -19,12 +19,9 @@ module Spree
19
19
  end
20
20
 
21
21
  def order_tracking_params
22
- tracking_params = {
22
+ {
23
23
  last_ip_address: request.remote_ip,
24
24
  }
25
-
26
- tracking_params[:ahoy_visit_id] = current_visit.id if @order.respond_to?(:ahoy_visit) && defined?(current_visit) && current_visit&.id
27
- tracking_params
28
25
  end
29
26
 
30
27
  def track_checkout_started
@@ -49,7 +49,9 @@ module Spree
49
49
  end
50
50
 
51
51
  def quick_checkout_enabled?(order)
52
- order.quick_checkout_available?
52
+ Rails.cache.fetch("#{order.cache_key_with_version}/quick-checkout-enabled") do
53
+ order.quick_checkout_available?
54
+ end
53
55
  end
54
56
 
55
57
  def can_use_store_credit_on_checkout?(order)
@@ -12,7 +12,7 @@ module Spree
12
12
  page ||= current_page
13
13
 
14
14
  sections = current_page_preview.present? ? current_page_preview.sections : page.sections
15
- sections_html = sections.includes(section_includes).map do |section|
15
+ sections_html = sections.includes(section_includes).preload_associations_lazily.map do |section|
16
16
  render_section(section, variables)
17
17
  end.join.html_safe
18
18
 
@@ -98,9 +98,7 @@ module Spree
98
98
  # @return [Array] the includes for the section
99
99
  def section_includes
100
100
  [
101
- :links, :rich_text_text,
102
- :rich_text_description, { asset_attachment: :blob },
103
- { blocks: [:rich_text_text, :links] }
101
+ { asset_attachment: :blob }
104
102
  ]
105
103
  end
106
104
 
@@ -15,15 +15,38 @@ module Spree
15
15
  ]
16
16
  end
17
17
 
18
- def should_display_compare_at_price?(product_or_variant)
19
- price = product_or_variant.price_in(current_currency)
20
- price.compare_at_amount.present? && (price.compare_at_amount > price.amount)
18
+ # Builds a pricing context for a variant with current request context
19
+ #
20
+ # @param product_or_variant [Spree::Product, Spree::Variant] The product or variant to build context for
21
+ # @param options [Hash] Optional overrides for context attributes
22
+ # @option options [String] :currency Override the currency (defaults to current_currency)
23
+ # @option options [Spree::Store] :store Override the store (defaults to current_store)
24
+ # @option options [Spree::Zone] :zone Override the zone (defaults to current_order.tax_zone || current_store.checkout_zone)
25
+ # @option options [Spree::User] :user Override the user (defaults to try_spree_current_user)
26
+ # @option options [Integer] :quantity Specify quantity for volume pricing
27
+ # @option options [Time] :date Specify date for date-based pricing
28
+ # @option options [Spree::Order] :order Specify the order
29
+ # @return [Spree::Pricing::Context] The pricing context
30
+ def pricing_context_for_variant(product_or_variant, **options)
31
+ variant = product_or_variant.is_a?(Spree::Product) ? product_or_variant.default_variant : product_or_variant
32
+
33
+ Spree::Pricing::Context.new(
34
+ variant: variant,
35
+ currency: options[:currency] || current_currency,
36
+ store: options[:store] || current_store,
37
+ zone: options[:zone] || current_order&.tax_zone || current_store.checkout_zone,
38
+ user: options[:user] || try_spree_current_user,
39
+ quantity: options[:quantity],
40
+ date: options[:date],
41
+ order: options[:order] || current_order
42
+ )
21
43
  end
22
44
 
23
- def weeks_online(product)
24
- Spree::Deprecation.warn('weeks_online is deprecated and will be removed in Spree 5.2')
25
-
26
- (Time.current - product.activated_at.in_time_zone(current_store.preferred_timezone)).seconds.in_weeks.to_i.abs
45
+ def should_display_compare_at_price?(product_or_variant)
46
+ variant = product_or_variant.is_a?(Spree::Product) ? product_or_variant.default_variant : product_or_variant
47
+ context = pricing_context_for_variant(variant)
48
+ price = variant.price_for(context)
49
+ price.compare_at_amount.present? && (price.compare_at_amount > price.amount)
27
50
  end
28
51
 
29
52
  def product_not_selected_options(product, selected_variant, options_param_name: :options)
@@ -147,7 +170,7 @@ module Spree
147
170
  return Spree::Taxon.none if product.main_taxon.blank?
148
171
 
149
172
  # using find_all as we already iterate over the taxons in #product_json_ld_breadcrumbs
150
- product.main_taxon.self_and_ancestors.find_all { |taxon| taxon.depth != 0 }
173
+ product.main_taxon.self_and_ancestors.includes(:translations).find_all { |taxon| taxon.depth != 0 }
151
174
  end
152
175
 
153
176
  # Generates the JSON-LD elements for a list of products.
@@ -12,7 +12,8 @@ module Spree
12
12
  @spree_storefront_base_cache_key ||= [
13
13
  spree_base_cache_key,
14
14
  current_wishlist,
15
- current_order
15
+ current_order,
16
+ Spree::Current.price_lists.cache_key_with_version
16
17
  ].compact
17
18
  end
18
19
 
@@ -12,7 +12,9 @@ module Spree
12
12
  sort_by: 'default'
13
13
  }
14
14
 
15
- storefront_products_finder.new(scope: current_store.products.includes(storefront_products_includes), params: finder_params).execute
15
+ scope = current_store.products.includes(storefront_products_includes).preload_associations_lazily
16
+
17
+ storefront_products_finder.new(scope: scope, params: finder_params).execute
16
18
  end
17
19
  end
18
20
  end
@@ -79,7 +79,7 @@ module Spree
79
79
  #
80
80
  # @return [Hash] the theme layout sections
81
81
  def theme_layout_sections
82
- Spree::Deprecation.warn('theme_layout_sections is deprecated and will be removed in Spree 6.0. Please use render_header_sections and render_footer_sections instead.')
82
+ Spree::Deprecation.warn('theme_layout_sections is deprecated and will be removed in Spree 5.5. Please use render_header_sections and render_footer_sections instead.')
83
83
 
84
84
  @theme_layout_sections ||= current_theme_or_preview.sections.includes(section_includes).all.each_with_object({}) do |section, hash|
85
85
  hash[section.type.to_s.demodulize.underscore] = section
@@ -33,7 +33,7 @@
33
33
  </div>
34
34
 
35
35
  <div class="flex flex-col items-center gap-4">
36
- <p class="text-sm text-gray-600"><%= Spree.t(:continue_without_logging_in) %></p>
36
+ <p class="text-sm text-muted"><%= Spree.t(:continue_without_logging_in) %></p>
37
37
  <%= link_to Spree.t(:continue_as_guest), spree.checkout_path(current_order.token, guest: true), class: 'btn btn-secondary w-full max-w-sm', data: { turbo: false } %>
38
38
  </div>
39
39
  <% end %>
@@ -73,7 +73,7 @@
73
73
  </h5>
74
74
  <% if !already_have_an_account? && defined?(spree_login_path) %>
75
75
  <div class="lg:text-right">
76
- <span class="text-gray-600 text-sm">
76
+ <span class="text-muted text-sm">
77
77
  <%= Spree.t('storefront.checkout.already_have_an_account') %> <span class="text-primary"><%= link_to Spree.t(:login), spree_login_path, data: { turbo_frame: '_top' } %></span>
78
78
  </span>
79
79
  </div>
@@ -134,7 +134,7 @@
134
134
  <%= render 'spree/checkout/special_instructions', form: form %>
135
135
 
136
136
  </div>
137
- <div class="flex justify-end w-full">
137
+ <div class="flex justify-end w-full gap-2">
138
138
  <%= button_tag Spree.t(:save_and_continue),
139
139
  class: 'btn-primary w-full lg:w-2/5 font-semibold checkout-content-save-continue-button my-5 !py-4',
140
140
  data: {
@@ -16,7 +16,7 @@
16
16
  <%= hidden_field_tag :coupon_code, promotion.code_for_order(@order) %>
17
17
  <div class="m-0">
18
18
  <div class="flex items-center justify-between text-sm">
19
- <span class="max-w-[250px] truncate flex items-center p-2 rounded-sm bg-gray-200">
19
+ <span class="max-w-[250px] truncate flex items-center p-2 rounded-sm bg-border">
20
20
  <%= heroicon('tag', options: { class: 'h-4 w-4 mr-2' }) %>
21
21
  <%= promotion.name_for_order(@order) %>
22
22
  </span>
@@ -31,7 +31,7 @@
31
31
  <%= hidden_field_tag :gift_card, @order.gift_card.code %>
32
32
  <div class="m-0">
33
33
  <div class="flex items-center justify-between text-sm">
34
- <span class="max-w-[250px] truncate flex items-center p-2 rounded-sm bg-gray-200">
34
+ <span class="max-w-[250px] truncate flex items-center p-2 rounded-sm bg-border">
35
35
  <%= heroicon('gift', options: { class: 'h-4 w-4 mr-2' }) %>
36
36
  <%= @order.gift_card.code.upcase %>
37
37
  </span>
@@ -24,8 +24,8 @@
24
24
  </div>
25
25
  </div>
26
26
  </div>
27
- <div class="flex justify-end w-full mt-5">
28
- <div class="flex justify-end w-full">
27
+ <div class="flex justify-end w-full gap-2 mt-5">
28
+ <div class="flex justify-end w-full gap-2">
29
29
  <%= button_tag Spree.t(:save_and_continue),
30
30
  class: 'btn-primary w-full lg:w-2/5 font-semibold checkout-content-save-continue-button my-5 !py-4',
31
31
  data: { action: 'click->checkout-delivery#disableShippingRates',
@@ -12,7 +12,7 @@
12
12
  <label class="select-none cursor-pointer px-2 word-break w-full" for="<%= "shipping-rate-#{rate.id}" %>">
13
13
  <%= rate.name %>
14
14
  <% if rate.delivery_range %>
15
- <span class="text-gray-600 text-xs ml-3"><%= rate.display_delivery_range %></span>
15
+ <span class="text-muted text-xs ml-3"><%= rate.display_delivery_range %></span>
16
16
  <% end %>
17
17
  </label>
18
18
  <span class="text-right">
@@ -1,7 +1,5 @@
1
1
  <%= turbo_frame_tag :checkout_line_items, id: 'line_items', target: '_top' do %>
2
- <% cache spree_storefront_base_cache_scope.call(order.line_items.cache_key_with_version) do %>
3
- <div class="overflow-y-auto line-items flex flex-col gap-5 pt-5 md:pt-0" data-checkout-summary-target="line_items">
4
- <%= render collection: order.line_items, partial: 'spree/checkout/line_item', cached: spree_storefront_base_cache_scope %>
5
- </div>
6
- <% end %>
2
+ <div class="overflow-y-auto line-items flex flex-col gap-5 pt-5 md:pt-0" data-checkout-summary-target="line_items">
3
+ <%= render collection: order.line_items, partial: 'spree/checkout/line_item', cached: spree_storefront_base_cache_scope %>
4
+ </div>
7
5
  <% end %>
@@ -39,7 +39,7 @@
39
39
 
40
40
  <%= render 'spree/checkout/terms_and_conditions' %>
41
41
 
42
- <div class="flex justify-end w-full">
42
+ <div class="flex justify-end w-full gap-2">
43
43
  <button type="submit"
44
44
  id="checkout-payment-submit"
45
45
  class="btn-primary w-full lg:w-2/5 font-semibold checkout-content-save-continue-button my-5 !py-4"
@@ -1 +1 @@
1
- <%= render_page(current_page, products: storefront_products.records, sort: products_sort) %>
1
+ <%= render_page(current_page, products: storefront_products, sort: products_sort) %>
@@ -1,6 +1,6 @@
1
1
  <%= render_page(
2
2
  current_page,
3
- products: storefront_products.records,
3
+ products: storefront_products,
4
4
  query: query,
5
5
  sort: products_sort
6
6
  ) %>