spree_frontend 4.2.4 → 4.3.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/app/assets/config/spree_frontend_manifest.js +4 -0
  4. data/app/assets/images/arrow-right-circle-fill.svg +3 -0
  5. data/app/assets/images/card-image.svg +4 -0
  6. data/app/assets/images/file-image.svg +4 -0
  7. data/app/assets/images/image.svg +4 -0
  8. data/app/assets/images/noimage/large.png +0 -0
  9. data/app/assets/images/noimage/mini.png +0 -0
  10. data/app/assets/images/noimage/plp.svg +23 -0
  11. data/app/assets/images/noimage/product.png +0 -0
  12. data/app/assets/images/noimage/small.png +0 -0
  13. data/app/assets/javascripts/spree/api/main.js +36 -0
  14. data/app/assets/javascripts/spree/api/storefront/cart.js +49 -0
  15. data/app/assets/javascripts/spree/frontend/checkout/payment.js +18 -5
  16. data/app/assets/javascripts/spree/frontend/checkout.js +16 -0
  17. data/app/assets/javascripts/spree/frontend/currency.js +11 -9
  18. data/app/assets/javascripts/spree/frontend/locale.es6 +13 -0
  19. data/app/assets/javascripts/spree/frontend/views/spree/home/product_carousels.js +3 -3
  20. data/app/assets/javascripts/spree/frontend/views/spree/products/index.js +0 -9
  21. data/app/assets/javascripts/spree/frontend/views/spree/products/price_filters.es6 +46 -0
  22. data/app/assets/javascripts/spree/frontend.js +3 -0
  23. data/app/assets/javascripts/spree.js +78 -0
  24. data/app/assets/stylesheets/spree/frontend/application.scss +1 -0
  25. data/app/assets/stylesheets/spree/frontend/components-bootstrap/button.scss +8 -0
  26. data/app/assets/stylesheets/spree/frontend/helpers/spree/frontend_helper.scss +41 -0
  27. data/app/assets/stylesheets/spree/frontend/variables/variables.scss +2 -2
  28. data/app/assets/stylesheets/spree/frontend/views/spree/checkout/edit.scss +17 -5
  29. data/app/assets/stylesheets/spree/frontend/views/spree/cms_sections/_index.scss +1 -0
  30. data/app/assets/stylesheets/spree/frontend/views/spree/cms_sections/product_buy_bar.scss +20 -0
  31. data/app/assets/stylesheets/spree/frontend/views/spree/home/index.scss +54 -67
  32. data/app/assets/stylesheets/spree/frontend/views/spree/shared/category_nav_bar.scss +3 -3
  33. data/app/assets/stylesheets/spree/frontend/views/spree/shared/footer.scss +4 -0
  34. data/app/assets/stylesheets/spree/frontend/views/spree/shared/main_nav_bar.scss +12 -1
  35. data/app/controllers/spree/addresses_controller.rb +14 -19
  36. data/app/controllers/spree/checkout_controller.rb +5 -3
  37. data/app/controllers/spree/cms_pages_controller.rb +29 -0
  38. data/app/controllers/spree/content_controller.rb +0 -2
  39. data/app/controllers/spree/errors_controller.rb +11 -0
  40. data/app/controllers/spree/home_controller.rb +34 -1
  41. data/app/controllers/spree/locale_controller.rb +7 -1
  42. data/app/controllers/spree/orders_controller.rb +9 -7
  43. data/app/controllers/spree/products_controller.rb +14 -13
  44. data/app/controllers/spree/store_controller.rb +25 -1
  45. data/app/controllers/spree/taxons_controller.rb +12 -5
  46. data/app/helpers/spree/addresses_helper.rb +9 -4
  47. data/app/helpers/spree/cms_pages_helper.rb +23 -0
  48. data/app/helpers/spree/frontend_helper.rb +109 -10
  49. data/app/helpers/spree/navigation_helper.rb +73 -4
  50. data/app/helpers/spree/products_filters_helper.rb +168 -0
  51. data/app/helpers/spree/store_helper.rb +3 -1
  52. data/app/views/spree/checkout/_address.html.erb +1 -1
  53. data/app/views/spree/checkout/_credit_card.html.erb +1 -0
  54. data/app/views/spree/cms_pages/show.html.erb +16 -0
  55. data/app/views/spree/errors/forbidden.html.erb +0 -0
  56. data/app/views/spree/errors/unauthorized.html.erb +0 -0
  57. data/app/views/spree/home/index.html.erb +19 -118
  58. data/app/views/spree/layouts/spree_application.html.erb +3 -2
  59. data/app/views/spree/products/_description.html.erb +16 -19
  60. data/app/views/spree/products/_filters_desktop.html.erb +50 -15
  61. data/app/views/spree/products/_filters_mobile.html.erb +38 -10
  62. data/app/views/spree/products/_sort_desktop.html.erb +17 -11
  63. data/app/views/spree/products/_sort_mobile.html.erb +16 -0
  64. data/app/views/spree/products/index.html.erb +1 -1
  65. data/app/views/spree/shared/_carousel_4_products.html.erb +8 -8
  66. data/app/views/spree/shared/_checkout_header.html.erb +22 -21
  67. data/app/views/spree/shared/_copyright.html.erb +1 -10
  68. data/app/views/spree/shared/_footer.html.erb +18 -12
  69. data/app/views/spree/shared/_get_started.html.erb +32 -0
  70. data/app/views/spree/shared/_head.html.erb +1 -1
  71. data/app/views/spree/shared/_header.html.erb +3 -3
  72. data/app/views/spree/shared/_main_nav_bar.html.erb +61 -43
  73. data/app/views/spree/shared/_mobile_navigation.html.erb +30 -19
  74. data/app/views/spree/shared/_nav_bar.html.erb +1 -1
  75. data/app/views/spree/shared/_option_values.html.erb +2 -21
  76. data/app/views/spree/shared/_order_details.html.erb +1 -1
  77. data/app/views/spree/shared/_paths.html.erb +8 -0
  78. data/app/views/spree/shared/_properties.html.erb +4 -0
  79. data/app/views/spree/shared/_translations.html.erb +2 -1
  80. data/app/views/spree/shared/carousel/_single.html.erb +1 -1
  81. data/app/views/spree/shared/carousel/_thumbnails.html.erb +1 -1
  82. data/app/views/spree/shared/cms/pages/_edit_mode.html.erb +13 -0
  83. data/app/views/spree/shared/cms/sections/_featured_article.html.erb +27 -0
  84. data/app/views/spree/shared/cms/sections/_hero_image.html.erb +60 -0
  85. data/app/views/spree/shared/cms/sections/_image_gallery.html.erb +171 -0
  86. data/app/views/spree/shared/cms/sections/_product_carousel.html.erb +5 -0
  87. data/app/views/spree/shared/cms/sections/_rich_text_content.html.erb +3 -0
  88. data/app/views/spree/shared/cms/sections/_side_by_side_images.html.erb +118 -0
  89. data/app/views/spree/taxons/_header.html.erb +6 -1
  90. data/app/views/spree/users/show.html.erb +4 -1
  91. data/config/initializers/assets.rb +4 -13
  92. data/config/routes.rb +9 -3
  93. data/lib/generators/spree/frontend/install/install_generator.rb +5 -5
  94. data/lib/generators/spree/frontend/install/templates/app/assets/config/manifest.js +2 -0
  95. data/lib/generators/spree/frontend/install/templates/vendor/assets/javascripts/spree/frontend/all.js +8 -0
  96. data/lib/generators/spree/frontend/install/templates/vendor/assets/stylesheets/spree/frontend/all.css +9 -0
  97. data/lib/spree/frontend/engine.rb +6 -0
  98. data/lib/spree/frontend.rb +6 -3
  99. data/spec/fixtures/files/store_favicon.ico +0 -0
  100. data/spree_frontend.gemspec +13 -9
  101. data/vendor/assets/javascripts/cleave.js +8 -0
  102. data/vendor/assets/javascripts/fetch.umd.js +531 -0
  103. data/vendor/assets/javascripts/jquery.payment.js +652 -0
  104. data/vendor/assets/javascripts/jsuri.js +458 -0
  105. data/vendor/assets/javascripts/polyfill.min.js +1 -0
  106. metadata +134 -87
  107. data/app/assets/images/homepage/big_category_banner.jpg +0 -0
  108. data/app/assets/images/homepage/big_category_banner_mobile.jpg +0 -0
  109. data/app/assets/images/homepage/big_category_banner_tablet_landscape.jpg +0 -0
  110. data/app/assets/images/homepage/big_category_banner_tablet_portrait.jpg +0 -0
  111. data/app/assets/images/homepage/category_banner_lower.jpg +0 -0
  112. data/app/assets/images/homepage/category_banner_lower_mobile.jpg +0 -0
  113. data/app/assets/images/homepage/category_banner_lower_tablet_landscape.jpg +0 -0
  114. data/app/assets/images/homepage/category_banner_lower_tablet_portrait.jpg +0 -0
  115. data/app/assets/images/homepage/category_banner_upper.jpg +0 -0
  116. data/app/assets/images/homepage/category_banner_upper_mobile.jpg +0 -0
  117. data/app/assets/images/homepage/category_banner_upper_tablet_landscape.jpg +0 -0
  118. data/app/assets/images/homepage/category_banner_upper_tablet_portrait.jpg +0 -0
  119. data/app/assets/images/homepage/main_banner.jpg +0 -0
  120. data/app/assets/images/homepage/main_banner_mobile.jpg +0 -0
  121. data/app/assets/images/homepage/main_banner_tablet_landscape.jpg +0 -0
  122. data/app/assets/images/homepage/main_banner_tablet_portrait.jpg +0 -0
  123. data/app/assets/images/homepage/promo_banner_left.jpg +0 -0
  124. data/app/assets/images/homepage/promo_banner_left_mobile.jpg +0 -0
  125. data/app/assets/images/homepage/promo_banner_left_tablet_landscape.jpg +0 -0
  126. data/app/assets/images/homepage/promo_banner_left_tablet_portrait.jpg +0 -0
  127. data/app/assets/images/homepage/promo_banner_right.jpg +0 -0
  128. data/app/assets/images/homepage/promo_banner_right_mobile.jpg +0 -0
  129. data/app/assets/images/homepage/promo_banner_right_tablet_landscape.jpg +0 -0
  130. data/app/assets/images/homepage/promo_banner_right_tablet_portrait.jpg +0 -0
  131. data/app/assets/images/meganav/promo_banner_left-first-category.jpg +0 -0
  132. data/app/assets/images/meganav/promo_banner_left-second-category.jpg +0 -0
  133. data/app/assets/images/meganav/promo_banner_left-third-category.jpg +0 -0
  134. data/app/assets/images/meganav/promo_banner_right-first-category.jpg +0 -0
  135. data/app/assets/images/meganav/promo_banner_right-second-category.jpg +0 -0
  136. data/app/assets/images/meganav/promo_banner_right-third-category.jpg +0 -0
  137. data/app/assets/images/noimage/big_category_banner.jpg +0 -0
  138. data/app/assets/images/noimage/big_category_banner_mobile.jpg +0 -0
  139. data/app/assets/images/noimage/big_category_banner_tablet_landscape.jpg +0 -0
  140. data/app/assets/images/noimage/big_category_banner_tablet_portrait.jpg +0 -0
  141. data/app/assets/images/noimage/category_banner.jpg +0 -0
  142. data/app/assets/images/noimage/category_banner_mobile.jpg +0 -0
  143. data/app/assets/images/noimage/category_banner_plp.jpg +0 -0
  144. data/app/assets/images/noimage/category_banner_tablet_landscape.jpg +0 -0
  145. data/app/assets/images/noimage/category_banner_tablet_portrait.jpg +0 -0
  146. data/app/assets/images/noimage/main_banner.jpg +0 -0
  147. data/app/assets/images/noimage/main_banner_mobile.jpg +0 -0
  148. data/app/assets/images/noimage/main_banner_tablet_landscape.jpg +0 -0
  149. data/app/assets/images/noimage/main_banner_tablet_portrait.jpg +0 -0
  150. data/app/assets/images/noimage/product_photo.jpg +0 -0
  151. data/app/assets/images/noimage/promo_banner.jpg +0 -0
  152. data/app/assets/images/noimage/promo_banner_megamenu.jpg +0 -0
  153. data/app/assets/images/noimage/promo_banner_mobile.jpg +0 -0
  154. data/app/assets/images/noimage/promo_banner_tablet_landscape.jpg +0 -0
  155. data/app/assets/images/noimage/promo_banner_tablet_portrait.jpg +0 -0
  156. data/app/assets/images/spark-logo@3x.png +0 -0
  157. data/app/assets/javascripts/spree/frontend/locale.js +0 -13
  158. data/app/assets/javascripts/spree/frontend/multi_currency.js +0 -13
  159. data/lib/generators/spree/frontend/install/templates/config/initializers/spree_storefront.rb +0 -1
  160. data/lib/generators/spree/frontend/install/templates/config/spree_storefront.yml +0 -99
@@ -10,7 +10,7 @@ module Spree
10
10
 
11
11
  def create
12
12
  @address = try_spree_current_user.addresses.build(address_params)
13
- if @address.save
13
+ if create_service.call(user: try_spree_current_user, address_params: @address.attributes).success?
14
14
  flash[:notice] = I18n.t(:successfully_created, scope: :address_book)
15
15
  redirect_to spree.account_path
16
16
  else
@@ -23,28 +23,15 @@ module Spree
23
23
  end
24
24
 
25
25
  def new
26
- @address = Spree::Address.default
26
+ @address = Spree::Address.new(country: current_store.default_country, user: try_spree_current_user)
27
27
  end
28
28
 
29
29
  def update
30
- if @address.editable?
31
- if @address.update(address_params)
32
- flash[:notice] = Spree.t(:successfully_updated, scope: :address_book)
33
- redirect_back_or_default(addresses_path)
34
- else
35
- render :edit
36
- end
30
+ if update_service.call(address: @address, address_params: address_params).success?
31
+ flash[:notice] = Spree.t(:successfully_updated, scope: :address_book)
32
+ redirect_back_or_default(addresses_path)
37
33
  else
38
- new_address = @address.clone
39
- new_address.attributes = address_params
40
- new_address.user_id = @address.user_id
41
- @address.update_attribute(:deleted_at, Time.current)
42
- if new_address.save
43
- flash[:notice] = Spree.t(:successfully_updated, scope: :address_book)
44
- redirect_back_or_default(addresses_path)
45
- else
46
- render :edit
47
- end
34
+ render :edit
48
35
  end
49
36
  end
50
37
 
@@ -60,5 +47,13 @@ module Spree
60
47
  def address_params
61
48
  params.require(:address).permit(permitted_address_attributes)
62
49
  end
50
+
51
+ def create_service
52
+ Spree::Dependencies.account_create_address_service.constantize
53
+ end
54
+
55
+ def update_service
56
+ Spree::Dependencies.account_update_address_service.constantize
57
+ end
63
58
  end
64
59
  end
@@ -141,8 +141,8 @@ module Spree
141
141
  def before_address
142
142
  # if the user has a default address, a callback takes care of setting
143
143
  # that; but if he doesn't, we need to build an empty one here
144
- @order.bill_address ||= Address.build_default
145
- @order.ship_address ||= Address.build_default if @order.checkout_steps.include?('delivery')
144
+ @order.bill_address ||= Address.new(country: current_store.default_country, user: try_spree_current_user)
145
+ @order.ship_address ||= Address.new(country: current_store.default_country, user: try_spree_current_user) if @order.checkout_steps.include?('delivery')
146
146
  end
147
147
 
148
148
  def before_delivery
@@ -161,7 +161,9 @@ module Spree
161
161
  end
162
162
  end
163
163
 
164
- @payment_sources = try_spree_current_user.payment_sources if try_spree_current_user&.respond_to?(:payment_sources)
164
+ return unless try_spree_current_user.respond_to?(:payment_sources)
165
+
166
+ @payment_sources = try_spree_current_user.payment_sources.where(payment_method: @order.available_payment_methods)
165
167
  end
166
168
 
167
169
  def add_store_credit_payments
@@ -0,0 +1,29 @@
1
+ module Spree
2
+ class CmsPagesController < Spree::StoreController
3
+ before_action :load_cms_page, only: [:show]
4
+
5
+ include Spree::FrontendHelper
6
+ include Spree::CacheHelper
7
+
8
+ def show
9
+ if @page&.visible?
10
+ @cms_page = @page
11
+ elsif @page&.draft_mode? && try_spree_current_user&.admin?
12
+ @cms_page = @page
13
+ @edit_mode = true
14
+ else
15
+ raise ActiveRecord::RecordNotFound
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def accurate_title
22
+ @page&.seo_title || super
23
+ end
24
+
25
+ def load_cms_page
26
+ @page = Spree::CmsPage.for_store(current_store).by_locale(I18n.locale).find_by(slug: params[:slug])
27
+ end
28
+ end
29
+ end
@@ -3,8 +3,6 @@ module Spree
3
3
  # Don't serve local files or static assets
4
4
  after_action :fire_visited_path, except: :cvv
5
5
 
6
- respond_to :html
7
-
8
6
  def test; end
9
7
 
10
8
  def cvv
@@ -0,0 +1,11 @@
1
+ module Spree
2
+ class ErrorsController < StoreController
3
+ def forbidden
4
+ render status: 403
5
+ end
6
+
7
+ def unauthorized
8
+ render status: 401
9
+ end
10
+ end
11
+ end
@@ -2,12 +2,45 @@ module Spree
2
2
  class HomeController < Spree::StoreController
3
3
  include Spree::CacheHelper
4
4
 
5
+ before_action :load_homepage, only: [:index]
6
+
5
7
  respond_to :html
6
8
 
7
9
  def index
10
+ if @cms_home_page&.visible?
11
+ @homepage = @cms_home_page
12
+ elsif try_spree_current_user&.admin?
13
+ @homepage = @cms_home_page
14
+ @edit_mode = true
15
+ end
16
+
8
17
  if http_cache_enabled?
9
- fresh_when etag: store_etag, last_modified: store_last_modified, public: true
18
+ fresh_when etag: store_etag, last_modified: last_modified_index, public: true
10
19
  end
11
20
  end
21
+
22
+ private
23
+
24
+ def etag_index
25
+ [
26
+ store_etag,
27
+ last_modified_index,
28
+ ]
29
+ end
30
+
31
+ def last_modified_index
32
+ page_last_modified = @cms_home_page&.maximum(:updated_at)&.utc if @cms_home_page.respond_to?(:maximum)
33
+ current_store_last_modified = current_store.updated_at.utc
34
+
35
+ [page_last_modified, current_store_last_modified].compact.max
36
+ end
37
+
38
+ def accurate_title
39
+ @cms_home_page&.seo_title || super
40
+ end
41
+
42
+ def load_homepage
43
+ @cms_home_page = current_store.homepage(I18n.locale)
44
+ end
12
45
  end
13
46
  end
@@ -1,5 +1,7 @@
1
1
  module Spree
2
2
  class LocaleController < Spree::StoreController
3
+ REDIRECT_TO_ROOT = /\/(#{Spree::Config[:storefront_pages_path]})\//.freeze
4
+
3
5
  def index
4
6
  render :index, layout: false
5
7
  end
@@ -25,7 +27,11 @@ module Spree
25
27
  private
26
28
 
27
29
  def should_build_new_url?
28
- request.env['HTTP_REFERER'].present? && request.env['HTTP_REFERER'] != request.env['REQUEST_URI']
30
+ if request.env['HTTP_REFERER'].match(REDIRECT_TO_ROOT)
31
+ false
32
+ else
33
+ request.env['HTTP_REFERER'].present? && request.env['HTTP_REFERER'] != request.env['REQUEST_URI']
34
+ end
29
35
  end
30
36
  end
31
37
  end
@@ -5,16 +5,14 @@ module Spree
5
5
 
6
6
  helper 'spree/products', 'spree/orders'
7
7
 
8
- respond_to :html
9
-
10
8
  before_action :assign_order_with_lock, only: :update
11
9
 
12
10
  def show
13
- @order = Order.includes(line_items: [variant: [:option_values, :images, :product]], bill_address: :state, ship_address: :state).find_by!(number: params[:id])
11
+ @order = current_store.orders.includes(line_items: [variant: [:option_values, :images, :product]], bill_address: :state, ship_address: :state).find_by!(number: params[:id])
14
12
  end
15
13
 
16
14
  def update
17
- @variant = Spree::Variant.find(params[:variant_id]) if params[:variant_id]
15
+ @variant = curret_store.variants.find(params[:variant_id]) if params[:variant_id]
18
16
  if Cart::Update.call(order: @order, params: order_params).success?
19
17
  respond_with(@order) do |format|
20
18
  format.html do
@@ -33,14 +31,14 @@ module Spree
33
31
 
34
32
  # Shows the current incomplete order from the session
35
33
  def edit
36
- @order = current_order || Order.incomplete.
34
+ @order = current_order || current_store.orders.incomplete.
37
35
  includes(line_items: [variant: [:images, :product, option_values: :option_type]]).
38
36
  find_or_initialize_by(token: cookies.signed[:token])
39
37
  associate_user
40
38
  end
41
39
 
42
40
  def empty
43
- current_order.try(:empty!)
41
+ cart_empty_service.call(order: current_order)
44
42
 
45
43
  redirect_to spree.cart_path
46
44
  end
@@ -56,7 +54,7 @@ module Spree
56
54
  end
57
55
 
58
56
  def check_authorization
59
- order = Spree::Order.find_by(number: params[:id]) if params[:id].present?
57
+ order = current_store.orders.find_by(number: params[:id]) if params[:id].present?
60
58
  order ||= current_order
61
59
 
62
60
  if order && action_name.to_sym == :show
@@ -87,5 +85,9 @@ module Spree
87
85
  def cart_add_item_service
88
86
  Spree::Dependencies.cart_add_item_service.constantize
89
87
  end
88
+
89
+ def cart_empty_service
90
+ Spree::Dependencies.cart_empty_service.constantize
91
+ end
90
92
  end
91
93
  end
@@ -7,10 +7,10 @@ module Spree
7
7
  before_action :load_product, only: [:show, :related]
8
8
  before_action :load_taxon, only: :index
9
9
 
10
- respond_to :html
10
+ before_action :can_show_product?, only: :show
11
11
 
12
12
  def index
13
- @searcher = build_searcher(params.merge(include_images: true, current_store_id: current_store.id))
13
+ @searcher = build_searcher(params.merge(include_images: true, current_store: current_store))
14
14
  @products = @searcher.retrieve_products
15
15
 
16
16
  if http_cache_enabled?
@@ -21,7 +21,8 @@ module Spree
21
21
  def show
22
22
  redirect_if_legacy_path
23
23
 
24
- @taxon = params[:taxon_id].present? ? Spree::Taxon.find(params[:taxon_id]) : @product.taxons.first
24
+ @taxon = params[:taxon_id].present? ? taxons_scope.find_by(id: params[:taxon_id]) : nil
25
+ @taxon = @product.taxons.first unless @taxon.present?
25
26
 
26
27
  if !http_cache_enabled? || stale?(etag: etag_show, last_modified: last_modified_show, public: true)
27
28
  @product_summary = Spree::ProductSummaryPresenter.new(@product).call
@@ -51,19 +52,15 @@ module Spree
51
52
  end
52
53
 
53
54
  def load_product
54
- @products = if try_spree_current_user.try(:has_spree_role?, 'admin')
55
- Product.with_deleted
56
- else
57
- Product.active(current_currency)
58
- end
59
-
60
- @product = @products.includes(:master).
61
- friendly.
62
- find(params[:id])
55
+ @product = current_store.products.for_user(try_spree_current_user).friendly.find(params[:id])
63
56
  end
64
57
 
65
58
  def load_taxon
66
- @taxon = Spree::Taxon.find(params[:taxon]) if params[:taxon].present?
59
+ @taxon = taxons_scope.find(params[:taxon]) if params[:taxon].present?
60
+ end
61
+
62
+ def can_show_product?
63
+ raise ActiveRecord::RecordNotFound if @product.stores.exclude?(current_store)
67
64
  end
68
65
 
69
66
  def load_variants
@@ -122,5 +119,9 @@ module Spree
122
119
 
123
120
  [product_last_modified, current_store_last_modified].compact.max
124
121
  end
122
+
123
+ def taxons_scope
124
+ current_store.taxons
125
+ end
125
126
  end
126
127
  end
@@ -1,8 +1,18 @@
1
1
  module Spree
2
- class StoreController < Spree::BaseController
2
+ class StoreController < ApplicationController
3
+ include Spree::Core::ControllerHelpers::Auth
4
+ include Spree::Core::ControllerHelpers::Common
5
+ include Spree::Core::ControllerHelpers::Search
6
+ include Spree::Core::ControllerHelpers::Store
7
+ include Spree::Core::ControllerHelpers::StrongParameters
8
+ include Spree::Core::ControllerHelpers::Locale
9
+ include Spree::Core::ControllerHelpers::Currency
3
10
  include Spree::Core::ControllerHelpers::Order
4
11
  include Spree::LocaleUrls
5
12
 
13
+ respond_to :html
14
+
15
+ helper 'spree/base'
6
16
  helper 'spree/locale'
7
17
  helper 'spree/currency'
8
18
 
@@ -50,5 +60,19 @@ module Spree
50
60
  def store_last_modified
51
61
  (current_store.updated_at || Time.current).utc
52
62
  end
63
+
64
+ def redirect_unauthorized_access
65
+ if try_spree_current_user
66
+ flash[:error] = Spree.t(:authorization_failure)
67
+ redirect_to spree.forbidden_path
68
+ else
69
+ store_location
70
+ if respond_to?(:spree_login_path)
71
+ redirect_to spree_login_path
72
+ else
73
+ redirect_to spree.root_path
74
+ end
75
+ end
76
+ end
53
77
  end
54
78
  end
@@ -6,8 +6,6 @@ module Spree
6
6
 
7
7
  before_action :load_taxon
8
8
 
9
- respond_to :html
10
-
11
9
  def show
12
10
  if !http_cache_enabled? || stale?(etag: etag, last_modified: last_modified, public: true)
13
11
  load_products
@@ -32,11 +30,17 @@ module Spree
32
30
  end
33
31
 
34
32
  def load_taxon
35
- @taxon = Spree::Taxon.friendly.find(params[:id])
33
+ @taxon = current_store.taxons.friendly.find(params[:id])
36
34
  end
37
35
 
38
36
  def load_products
39
- @searcher = build_searcher(params.merge(taxon: @taxon.id, include_images: true))
37
+ search_params = params.merge(
38
+ current_store: current_store,
39
+ taxon: @taxon,
40
+ include_images: true
41
+ )
42
+
43
+ @searcher = build_searcher(search_params)
40
44
  @products = @searcher.retrieve_products
41
45
  end
42
46
 
@@ -57,7 +61,10 @@ module Spree
57
61
  end
58
62
 
59
63
  def last_modified
60
- @taxon.updated_at&.utc
64
+ taxon_last_modified = @taxon&.updated_at&.utc
65
+ current_store_last_modified = current_store.updated_at.utc
66
+
67
+ [taxon_last_modified, current_store_last_modified].compact.max
61
68
  end
62
69
  end
63
70
  end
@@ -22,7 +22,7 @@ module Spree
22
22
  end
23
23
 
24
24
  def address_zipcode(form, country, address_id = 'b')
25
- country ||= Spree::Country.default
25
+ country ||= address_default_country
26
26
  is_required = country.zipcode_required?
27
27
  method_name = Spree.t(:zipcode)
28
28
  required = Spree.t(:required)
@@ -38,7 +38,7 @@ module Spree
38
38
  end
39
39
 
40
40
  def address_state(form, country, address_id = 'b')
41
- country ||= Spree::Country.find(Spree::Config[:default_country_id])
41
+ country ||= address_default_country
42
42
  have_states = country.states.any?
43
43
  state_elements = [
44
44
  form.collection_select(:state_id, checkout_zone_applicable_states_for(country).sort_by(&:name),
@@ -60,8 +60,9 @@ module Spree
60
60
  class: [!have_states ? 'hidden' : nil, 'position-absolute spree-flat-select-arrow'].compact)
61
61
  ].join.tr('"', "'").delete("\n")
62
62
 
63
- content_tag(:noscript, form.text_field(:state_name)) +
64
- javascript_tag("document.write(\"<span class='d-block position-relative'>#{state_elements.html_safe}</span>\");")
63
+ content_tag :span, class: 'd-block position-relative' do
64
+ state_elements.html_safe
65
+ end
65
66
  end
66
67
 
67
68
  def user_available_addresses
@@ -80,5 +81,9 @@ module Spree
80
81
  def checkout_zone_applicable_states_for(country)
81
82
  current_store.states_available_for_checkout(country)
82
83
  end
84
+
85
+ def address_default_country
86
+ @address_default_country ||= current_store.default_country
87
+ end
83
88
  end
84
89
  end
@@ -0,0 +1,23 @@
1
+ module Spree
2
+ module CmsPagesHelper
3
+ def simple_page?(page)
4
+ page.content.present? && !page.sections?
5
+ end
6
+
7
+ def section_tags(section, &block)
8
+ inner_content = content_tag(:div, class: section.css_classes, &block)
9
+
10
+ if section.fullscreen?
11
+ inner_content
12
+ else
13
+ content_tag(:div, inner_content, class: 'container')
14
+ end
15
+ end
16
+
17
+ def build_section(section)
18
+ section_tags(section) do
19
+ render "spree/shared/cms/sections/#{spree_resource_path(section)}", section: section
20
+ end
21
+ end
22
+ end
23
+ end