spree_frontend 4.2.5 → 4.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/app/assets/config/spree_frontend_manifest.js +4 -0
- data/app/assets/images/arrow-right-circle-fill.svg +3 -0
- data/app/assets/images/card-image.svg +4 -0
- data/app/assets/images/file-image.svg +4 -0
- data/app/assets/images/image.svg +4 -0
- data/app/assets/images/noimage/large.png +0 -0
- data/app/assets/images/noimage/mini.png +0 -0
- data/app/assets/images/noimage/plp.svg +23 -0
- data/app/assets/images/noimage/product.png +0 -0
- data/app/assets/images/noimage/small.png +0 -0
- data/app/assets/javascripts/spree/api/main.js +36 -0
- data/app/assets/javascripts/spree/api/storefront/cart.js +49 -0
- data/app/assets/javascripts/spree/frontend/checkout/payment.js +18 -5
- data/app/assets/javascripts/spree/frontend/checkout.js +16 -0
- data/app/assets/javascripts/spree/frontend/locale.es6 +13 -0
- data/app/assets/javascripts/spree/frontend/views/spree/home/product_carousels.js +3 -3
- data/app/assets/javascripts/spree/frontend/views/spree/products/index.js +0 -9
- data/app/assets/javascripts/spree/frontend/views/spree/products/price_filters.es6 +46 -0
- data/app/assets/javascripts/spree/frontend.js +3 -0
- data/app/assets/javascripts/spree.js +78 -0
- data/app/assets/stylesheets/spree/frontend/application.scss +1 -0
- data/app/assets/stylesheets/spree/frontend/components-bootstrap/button.scss +8 -0
- data/app/assets/stylesheets/spree/frontend/helpers/spree/frontend_helper.scss +41 -0
- data/app/assets/stylesheets/spree/frontend/variables/variables.scss +2 -2
- data/app/assets/stylesheets/spree/frontend/views/spree/checkout/edit.scss +17 -5
- data/app/assets/stylesheets/spree/frontend/views/spree/cms_sections/_index.scss +1 -0
- data/app/assets/stylesheets/spree/frontend/views/spree/cms_sections/product_buy_bar.scss +20 -0
- data/app/assets/stylesheets/spree/frontend/views/spree/home/index.scss +54 -67
- data/app/assets/stylesheets/spree/frontend/views/spree/shared/category_nav_bar.scss +3 -3
- data/app/assets/stylesheets/spree/frontend/views/spree/shared/footer.scss +4 -0
- data/app/assets/stylesheets/spree/frontend/views/spree/shared/main_nav_bar.scss +12 -1
- data/app/controllers/spree/addresses_controller.rb +14 -23
- data/app/controllers/spree/checkout_controller.rb +5 -3
- data/app/controllers/spree/cms_pages_controller.rb +29 -0
- data/app/controllers/spree/content_controller.rb +0 -2
- data/app/controllers/spree/errors_controller.rb +11 -0
- data/app/controllers/spree/home_controller.rb +34 -1
- data/app/controllers/spree/locale_controller.rb +7 -1
- data/app/controllers/spree/orders_controller.rb +9 -7
- data/app/controllers/spree/products_controller.rb +14 -13
- data/app/controllers/spree/store_controller.rb +25 -1
- data/app/controllers/spree/taxons_controller.rb +12 -5
- data/app/helpers/spree/addresses_helper.rb +9 -4
- data/app/helpers/spree/cms_pages_helper.rb +23 -0
- data/app/helpers/spree/frontend_helper.rb +109 -10
- data/app/helpers/spree/navigation_helper.rb +73 -4
- data/app/helpers/spree/products_filters_helper.rb +168 -0
- data/app/helpers/spree/store_helper.rb +3 -1
- data/app/views/spree/checkout/_address.html.erb +1 -1
- data/app/views/spree/checkout/_credit_card.html.erb +1 -0
- data/app/views/spree/cms_pages/show.html.erb +16 -0
- data/app/views/spree/errors/forbidden.html.erb +0 -0
- data/app/views/spree/errors/unauthorized.html.erb +0 -0
- data/app/views/spree/home/index.html.erb +19 -118
- data/app/views/spree/layouts/spree_application.html.erb +3 -2
- data/app/views/spree/products/_description.html.erb +16 -19
- data/app/views/spree/products/_filters_desktop.html.erb +50 -15
- data/app/views/spree/products/_filters_mobile.html.erb +38 -10
- data/app/views/spree/products/_sort_desktop.html.erb +17 -11
- data/app/views/spree/products/_sort_mobile.html.erb +16 -0
- data/app/views/spree/products/index.html.erb +1 -1
- data/app/views/spree/shared/_carousel_4_products.html.erb +8 -8
- data/app/views/spree/shared/_checkout_header.html.erb +22 -21
- data/app/views/spree/shared/_copyright.html.erb +1 -10
- data/app/views/spree/shared/_footer.html.erb +18 -12
- data/app/views/spree/shared/_get_started.html.erb +32 -0
- data/app/views/spree/shared/_head.html.erb +1 -1
- data/app/views/spree/shared/_header.html.erb +3 -3
- data/app/views/spree/shared/_main_nav_bar.html.erb +61 -43
- data/app/views/spree/shared/_mobile_navigation.html.erb +30 -19
- data/app/views/spree/shared/_nav_bar.html.erb +1 -1
- data/app/views/spree/shared/_option_values.html.erb +2 -21
- data/app/views/spree/shared/_order_details.html.erb +1 -1
- data/app/views/spree/shared/_paths.html.erb +8 -0
- data/app/views/spree/shared/_properties.html.erb +4 -0
- data/app/views/spree/shared/_translations.html.erb +2 -1
- data/app/views/spree/shared/carousel/_single.html.erb +1 -1
- data/app/views/spree/shared/carousel/_thumbnails.html.erb +1 -1
- data/app/views/spree/shared/cms/pages/_edit_mode.html.erb +13 -0
- data/app/views/spree/shared/cms/sections/_featured_article.html.erb +27 -0
- data/app/views/spree/shared/cms/sections/_hero_image.html.erb +60 -0
- data/app/views/spree/shared/cms/sections/_image_gallery.html.erb +171 -0
- data/app/views/spree/shared/cms/sections/_product_carousel.html.erb +5 -0
- data/app/views/spree/shared/cms/sections/_rich_text_content.html.erb +3 -0
- data/app/views/spree/shared/cms/sections/_side_by_side_images.html.erb +118 -0
- data/app/views/spree/taxons/_header.html.erb +6 -1
- data/app/views/spree/users/show.html.erb +4 -1
- data/config/initializers/assets.rb +4 -13
- data/config/routes.rb +10 -4
- data/lib/generators/spree/frontend/install/install_generator.rb +5 -5
- data/lib/generators/spree/frontend/install/templates/app/assets/config/manifest.js +2 -0
- data/lib/generators/spree/frontend/install/templates/vendor/assets/javascripts/spree/frontend/all.js +8 -0
- data/lib/generators/spree/frontend/install/templates/vendor/assets/stylesheets/spree/frontend/all.css +9 -0
- data/lib/spree/frontend/engine.rb +6 -0
- data/lib/spree/frontend.rb +6 -3
- data/spec/fixtures/files/store_favicon.ico +0 -0
- data/spree_frontend.gemspec +8 -4
- data/vendor/assets/javascripts/cleave.js +8 -0
- data/vendor/assets/javascripts/fetch.umd.js +531 -0
- data/vendor/assets/javascripts/jquery.payment.js +652 -0
- data/vendor/assets/javascripts/jsuri.js +458 -0
- data/vendor/assets/javascripts/polyfill.min.js +1 -0
- metadata +117 -70
- data/app/assets/images/homepage/big_category_banner.jpg +0 -0
- data/app/assets/images/homepage/big_category_banner_mobile.jpg +0 -0
- data/app/assets/images/homepage/big_category_banner_tablet_landscape.jpg +0 -0
- data/app/assets/images/homepage/big_category_banner_tablet_portrait.jpg +0 -0
- data/app/assets/images/homepage/category_banner_lower.jpg +0 -0
- data/app/assets/images/homepage/category_banner_lower_mobile.jpg +0 -0
- data/app/assets/images/homepage/category_banner_lower_tablet_landscape.jpg +0 -0
- data/app/assets/images/homepage/category_banner_lower_tablet_portrait.jpg +0 -0
- data/app/assets/images/homepage/category_banner_upper.jpg +0 -0
- data/app/assets/images/homepage/category_banner_upper_mobile.jpg +0 -0
- data/app/assets/images/homepage/category_banner_upper_tablet_landscape.jpg +0 -0
- data/app/assets/images/homepage/category_banner_upper_tablet_portrait.jpg +0 -0
- data/app/assets/images/homepage/main_banner.jpg +0 -0
- data/app/assets/images/homepage/main_banner_mobile.jpg +0 -0
- data/app/assets/images/homepage/main_banner_tablet_landscape.jpg +0 -0
- data/app/assets/images/homepage/main_banner_tablet_portrait.jpg +0 -0
- data/app/assets/images/homepage/promo_banner_left.jpg +0 -0
- data/app/assets/images/homepage/promo_banner_left_mobile.jpg +0 -0
- data/app/assets/images/homepage/promo_banner_left_tablet_landscape.jpg +0 -0
- data/app/assets/images/homepage/promo_banner_left_tablet_portrait.jpg +0 -0
- data/app/assets/images/homepage/promo_banner_right.jpg +0 -0
- data/app/assets/images/homepage/promo_banner_right_mobile.jpg +0 -0
- data/app/assets/images/homepage/promo_banner_right_tablet_landscape.jpg +0 -0
- data/app/assets/images/homepage/promo_banner_right_tablet_portrait.jpg +0 -0
- data/app/assets/images/meganav/promo_banner_left-first-category.jpg +0 -0
- data/app/assets/images/meganav/promo_banner_left-second-category.jpg +0 -0
- data/app/assets/images/meganav/promo_banner_left-third-category.jpg +0 -0
- data/app/assets/images/meganav/promo_banner_right-first-category.jpg +0 -0
- data/app/assets/images/meganav/promo_banner_right-second-category.jpg +0 -0
- data/app/assets/images/meganav/promo_banner_right-third-category.jpg +0 -0
- data/app/assets/images/noimage/big_category_banner.jpg +0 -0
- data/app/assets/images/noimage/big_category_banner_mobile.jpg +0 -0
- data/app/assets/images/noimage/big_category_banner_tablet_landscape.jpg +0 -0
- data/app/assets/images/noimage/big_category_banner_tablet_portrait.jpg +0 -0
- data/app/assets/images/noimage/category_banner.jpg +0 -0
- data/app/assets/images/noimage/category_banner_mobile.jpg +0 -0
- data/app/assets/images/noimage/category_banner_plp.jpg +0 -0
- data/app/assets/images/noimage/category_banner_tablet_landscape.jpg +0 -0
- data/app/assets/images/noimage/category_banner_tablet_portrait.jpg +0 -0
- data/app/assets/images/noimage/main_banner.jpg +0 -0
- data/app/assets/images/noimage/main_banner_mobile.jpg +0 -0
- data/app/assets/images/noimage/main_banner_tablet_landscape.jpg +0 -0
- data/app/assets/images/noimage/main_banner_tablet_portrait.jpg +0 -0
- data/app/assets/images/noimage/product_photo.jpg +0 -0
- data/app/assets/images/noimage/promo_banner.jpg +0 -0
- data/app/assets/images/noimage/promo_banner_megamenu.jpg +0 -0
- data/app/assets/images/noimage/promo_banner_mobile.jpg +0 -0
- data/app/assets/images/noimage/promo_banner_tablet_landscape.jpg +0 -0
- data/app/assets/images/noimage/promo_banner_tablet_portrait.jpg +0 -0
- data/app/assets/images/spark-logo@3x.png +0 -0
- data/app/assets/javascripts/spree/frontend/locale.js +0 -13
- data/app/assets/javascripts/spree/frontend/multi_currency.js +0 -13
- data/lib/generators/spree/frontend/install/templates/config/initializers/spree_storefront.rb +0 -1
- data/lib/generators/spree/frontend/install/templates/config/spree_storefront.yml +0 -99
@@ -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.
|
145
|
-
@order.ship_address ||= Address.
|
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
|
-
|
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
|
@@ -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:
|
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
|
-
|
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 =
|
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 =
|
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 ||
|
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
|
-
|
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 =
|
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
|
-
|
10
|
+
before_action :can_show_product?, only: :show
|
11
11
|
|
12
12
|
def index
|
13
|
-
@searcher = build_searcher(params.merge(include_images: true,
|
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? ?
|
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
|
-
@
|
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 =
|
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 <
|
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 =
|
33
|
+
@taxon = current_store.taxons.friendly.find(params[:id])
|
36
34
|
end
|
37
35
|
|
38
36
|
def load_products
|
39
|
-
|
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
|
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 ||=
|
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 ||=
|
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
|
64
|
-
|
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
|
@@ -1,5 +1,6 @@
|
|
1
1
|
module Spree
|
2
2
|
module FrontendHelper
|
3
|
+
include BaseHelper
|
3
4
|
include InlineSvg::ActionView::Helpers
|
4
5
|
|
5
6
|
def body_class
|
@@ -7,6 +8,22 @@ module Spree
|
|
7
8
|
@body_class
|
8
9
|
end
|
9
10
|
|
11
|
+
def logo(image_path = nil, options = {})
|
12
|
+
image_path ||= if current_store.logo.attached? && current_store.logo.variable?
|
13
|
+
main_app.url_for(current_store.logo.variant(resize: '244x104>'))
|
14
|
+
elsif current_store.logo.attached? && current_store.logo.image?
|
15
|
+
main_app.url_for(current_store.logo)
|
16
|
+
else
|
17
|
+
Spree::Config[:logo]
|
18
|
+
end
|
19
|
+
|
20
|
+
path = spree.respond_to?(:root_path) ? spree.root_path : main_app.root_path
|
21
|
+
|
22
|
+
link_to path, 'aria-label': current_store.name, method: options[:method] do
|
23
|
+
image_tag image_path, alt: current_store.name, title: current_store.name
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
10
27
|
def spree_breadcrumbs(taxon, _separator = '', product = nil)
|
11
28
|
return '' if current_page?('/') || taxon.nil?
|
12
29
|
|
@@ -137,10 +154,10 @@ module Spree
|
|
137
154
|
end
|
138
155
|
|
139
156
|
def asset_exists?(path)
|
140
|
-
if Rails.
|
141
|
-
Rails.application.
|
157
|
+
if Rails.configuration.assets.compile
|
158
|
+
Rails.application.precompiled_assets.include? path
|
142
159
|
else
|
143
|
-
Rails.application.assets
|
160
|
+
Rails.application.assets_manifest.assets[path].present?
|
144
161
|
end
|
145
162
|
end
|
146
163
|
|
@@ -150,7 +167,7 @@ module Spree
|
|
150
167
|
image_url = if image.present?
|
151
168
|
main_app.url_for(image.url('plp'))
|
152
169
|
else
|
153
|
-
asset_path('noimage/plp.
|
170
|
+
asset_path('noimage/plp.svg')
|
154
171
|
end
|
155
172
|
|
156
173
|
image_style = image&.style(:plp)
|
@@ -228,6 +245,11 @@ module Spree
|
|
228
245
|
end
|
229
246
|
|
230
247
|
def price_filter_values
|
248
|
+
ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller)
|
249
|
+
`FrontendHelper#price_filter_values` is deprecated and will be removed in Spree 5.0.
|
250
|
+
Please use `ProductsFiltersHelper#price_filters` method
|
251
|
+
DEPRECATION
|
252
|
+
|
231
253
|
@price_filter_values ||= [
|
232
254
|
"#{I18n.t('activerecord.attributes.spree/product.less_than')} #{formatted_price(50)}",
|
233
255
|
"#{formatted_price(50)} - #{formatted_price(100)}",
|
@@ -250,18 +272,81 @@ module Spree
|
|
250
272
|
end
|
251
273
|
|
252
274
|
def filtering_params_cache_key
|
253
|
-
@filtering_params_cache_key ||=
|
275
|
+
@filtering_params_cache_key ||= begin
|
276
|
+
cache_key_parts = []
|
277
|
+
|
278
|
+
permitted_products_params.each do |key, value|
|
279
|
+
next if value.blank?
|
280
|
+
|
281
|
+
if value.is_a?(String)
|
282
|
+
cache_key_parts << [key, value].join('-')
|
283
|
+
else
|
284
|
+
value.each do |part_key, part_value|
|
285
|
+
next if part_value.blank?
|
286
|
+
|
287
|
+
cache_key_parts << [part_key, part_value].join('-')
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
cache_key_parts.join('-').parameterize
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
def filters_cache_key(kind)
|
297
|
+
base_cache_key + [
|
298
|
+
kind,
|
299
|
+
available_option_types_cache_key,
|
300
|
+
available_properties_cache_key,
|
301
|
+
filtering_params_cache_key,
|
302
|
+
@taxon&.id,
|
303
|
+
params[:menu_open]
|
304
|
+
].flatten
|
305
|
+
end
|
306
|
+
|
307
|
+
def permitted_products_params
|
308
|
+
@permitted_products_params ||= begin
|
309
|
+
params.permit(*filtering_params, properties: available_properties.map(&:filter_param))
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
def option_type_cache_key(option_type)
|
314
|
+
filter_param = option_type.filter_param
|
315
|
+
filtered_params = params[filter_param]
|
316
|
+
|
317
|
+
[
|
318
|
+
available_option_types_cache_key,
|
319
|
+
filter_param,
|
320
|
+
filtered_params
|
321
|
+
]
|
254
322
|
end
|
255
323
|
|
256
324
|
def available_option_types_cache_key
|
257
|
-
@available_option_types_cache_key ||=
|
325
|
+
@available_option_types_cache_key ||= [
|
326
|
+
Spree::OptionType.filterable.maximum(:updated_at).to_f,
|
327
|
+
products_for_filters_cache_key
|
328
|
+
].flatten.join('/')
|
258
329
|
end
|
259
330
|
|
260
331
|
def available_option_types
|
261
332
|
@available_option_types ||= Rails.cache.fetch("available-option-types/#{available_option_types_cache_key}") do
|
262
|
-
|
333
|
+
option_values = OptionValues::FindAvailable.new(products_scope: products_for_filters).execute
|
334
|
+
Filters::OptionsPresenter.new(option_values_scope: option_values).to_a
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
def available_properties_cache_key
|
339
|
+
@available_properties_cache_key ||= [
|
340
|
+
Spree::Property.filterable.maximum(:updated_at).to_f,
|
341
|
+
products_for_filters_cache_key
|
342
|
+
].flatten.join('/')
|
343
|
+
end
|
344
|
+
|
345
|
+
def available_properties
|
346
|
+
@available_properties ||= Rails.cache.fetch("available-properties/#{available_properties_cache_key}") do
|
347
|
+
product_properties = ProductProperties::FindAvailable.new(products_scope: products_for_filters).execute
|
348
|
+
Filters::PropertiesPresenter.new(product_properties_scope: product_properties).to_a
|
263
349
|
end
|
264
|
-
@available_option_types
|
265
350
|
end
|
266
351
|
|
267
352
|
def spree_social_link(service)
|
@@ -275,7 +360,7 @@ module Spree
|
|
275
360
|
end
|
276
361
|
|
277
362
|
def checkout_available_payment_methods
|
278
|
-
@checkout_available_payment_methods ||= @order.available_payment_methods
|
363
|
+
@checkout_available_payment_methods ||= @order.available_payment_methods
|
279
364
|
end
|
280
365
|
|
281
366
|
def color_option_type_name
|
@@ -305,7 +390,7 @@ module Spree
|
|
305
390
|
end
|
306
391
|
|
307
392
|
def checkout_edit_link(step = 'address', order = @order)
|
308
|
-
return if order.
|
393
|
+
return if order.uneditable?
|
309
394
|
|
310
395
|
classes = 'align-text-bottom checkout-confirm-delivery-informations-link'
|
311
396
|
|
@@ -313,5 +398,19 @@ module Spree
|
|
313
398
|
inline_svg_tag 'edit.svg'
|
314
399
|
end
|
315
400
|
end
|
401
|
+
|
402
|
+
def products_for_filters
|
403
|
+
@products_for_filters ||= current_store.products.for_filters(current_currency, taxon: @taxon)
|
404
|
+
end
|
405
|
+
|
406
|
+
def products_for_filters_cache_key
|
407
|
+
@products_for_filters_cache_key ||= begin
|
408
|
+
[
|
409
|
+
products_for_filters.maximum(:updated_at).to_f,
|
410
|
+
base_cache_key,
|
411
|
+
@taxon&.permalink
|
412
|
+
].flatten.compact
|
413
|
+
end
|
414
|
+
end
|
316
415
|
end
|
317
416
|
end
|