spree_core 4.2.0.rc4 → 4.2.0.rc5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/spree/base_controller.rb +2 -1
- data/app/controllers/spree/errors_controller.rb +11 -0
- data/app/finders/spree/orders/find_current.rb +1 -1
- data/app/finders/spree/products/find.rb +12 -1
- data/app/helpers/spree/locale_helper.rb +19 -0
- data/app/helpers/spree/products_helper.rb +37 -12
- data/app/models/concerns/spree/user_payment_source.rb +1 -1
- data/app/models/spree/app_configuration.rb +1 -1
- data/app/models/spree/image.rb +14 -14
- data/app/models/spree/product.rb +12 -15
- data/app/models/spree/promotion/rules/option_value.rb +1 -1
- data/app/models/spree/store.rb +21 -9
- data/app/models/spree/variant.rb +7 -7
- data/app/presenters/spree/variant_presenter.rb +2 -5
- data/app/services/spree/cart/estimate_shipping_rates.rb +1 -1
- data/app/views/spree/errors/forbidden.html.erb +0 -0
- data/app/views/spree/errors/unauthorized.html.erb +0 -0
- data/app/views/spree/shared/_base_mailer_stylesheets.html.erb +0 -2
- data/app/views/spree/shared/purchased_items_table/_line_item.html.erb +1 -1
- data/config/locales/en.yml +0 -47
- data/config/routes.rb +2 -1
- data/db/default/spree/stores.rb +1 -0
- data/db/migrate/20210120142527_ensure_default_locale_in_spree_stores.rb +5 -0
- data/lib/generators/spree/install/templates/config/spree_storefront.yml +9 -9
- data/lib/spree/core.rb +2 -1
- data/lib/spree/core/controller_helpers/auth.rb +3 -1
- data/lib/spree/core/controller_helpers/common.rb +6 -8
- data/lib/spree/core/controller_helpers/currency.rb +45 -0
- data/lib/spree/core/controller_helpers/locale.rb +57 -0
- data/lib/spree/core/controller_helpers/store.rb +0 -16
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/testing_support/factories/stock_location_factory.rb +2 -2
- metadata +11 -5
- data/lib/spree/core/controller_helpers/currency_helpers.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d0f9d56b3e68e0ff69cfa46d00d61872b775e2e92ddf76a3eccd85899ca863b
|
4
|
+
data.tar.gz: 80879be83858cb06f69c5e78f975b9cbf1846941d62282290c8403bd8b509363
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82e15e51f5847c472eac8cd4e24e549dc28705b328f082860009c638277f203adbfe42ff898105862e3385b4ed5935e102200cd247ee998b09b4b2f3912b77d3
|
7
|
+
data.tar.gz: c843177415698e0d50d2d9d81b2803f84713db0dfe7d9098c41a7de69cb9c1c15158d97b93a2ecc97dc62752078797adbd03436bad2a8674c87eef07ecb97e35
|
@@ -7,7 +7,8 @@ class Spree::BaseController < ApplicationController
|
|
7
7
|
include Spree::Core::ControllerHelpers::Search
|
8
8
|
include Spree::Core::ControllerHelpers::Store
|
9
9
|
include Spree::Core::ControllerHelpers::StrongParameters
|
10
|
-
include Spree::Core::ControllerHelpers::
|
10
|
+
include Spree::Core::ControllerHelpers::Locale
|
11
|
+
include Spree::Core::ControllerHelpers::Currency
|
11
12
|
|
12
13
|
respond_to :html
|
13
14
|
end
|
@@ -9,7 +9,7 @@ module Spree
|
|
9
9
|
return order unless order.nil?
|
10
10
|
return if user.nil?
|
11
11
|
|
12
|
-
incomplete_orders.order(created_at: :desc).find_by(store: store, user: user)
|
12
|
+
incomplete_orders.order(created_at: :desc).find_by(store: store, user: user, currency: params[:currency])
|
13
13
|
end
|
14
14
|
|
15
15
|
private
|
@@ -22,6 +22,7 @@ module Spree
|
|
22
22
|
products = by_ids(scope)
|
23
23
|
products = by_skus(products)
|
24
24
|
products = by_price(products)
|
25
|
+
products = by_currency(products)
|
25
26
|
products = by_taxons(products)
|
26
27
|
products = by_concat_taxons(products)
|
27
28
|
products = by_name(products)
|
@@ -51,6 +52,10 @@ module Spree
|
|
51
52
|
price.present?
|
52
53
|
end
|
53
54
|
|
55
|
+
def currency?
|
56
|
+
currency.present?
|
57
|
+
end
|
58
|
+
|
54
59
|
def taxons?
|
55
60
|
taxons.present?
|
56
61
|
end
|
@@ -94,7 +99,7 @@ module Spree
|
|
94
99
|
def by_price(products)
|
95
100
|
return products unless price?
|
96
101
|
|
97
|
-
products.joins(master: :
|
102
|
+
products.joins(master: :prices).
|
98
103
|
where(
|
99
104
|
spree_prices: {
|
100
105
|
amount: price.min..price.max,
|
@@ -103,6 +108,12 @@ module Spree
|
|
103
108
|
)
|
104
109
|
end
|
105
110
|
|
111
|
+
def by_currency(products)
|
112
|
+
return products unless currency?
|
113
|
+
|
114
|
+
products.joins(master: :prices).where(spree_prices: { currency: currency })
|
115
|
+
end
|
116
|
+
|
106
117
|
def by_taxons(products)
|
107
118
|
return products unless taxons?
|
108
119
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Spree
|
2
|
+
module LocaleHelper
|
3
|
+
def all_locales_options
|
4
|
+
supported_locales_for_all_stores.map { |locale| locale_presentation(locale) }
|
5
|
+
end
|
6
|
+
|
7
|
+
def available_locales_options
|
8
|
+
available_locales.map { |locale| locale_presentation(locale) }
|
9
|
+
end
|
10
|
+
|
11
|
+
def locale_presentation(locale)
|
12
|
+
if defined?(SpreeI18n)
|
13
|
+
[Spree.t('i18n.this_file_language', locale: locale), locale]
|
14
|
+
else
|
15
|
+
locale.to_s == 'en' ? ['English (US)', :en] : [locale, locale]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -35,6 +35,11 @@ module Spree
|
|
35
35
|
variants_option_types_presenter(variants, product).default_variant || product.default_variant
|
36
36
|
end
|
37
37
|
|
38
|
+
def should_display_compare_at_price?(default_variant)
|
39
|
+
default_variant_price = default_variant.price_in(current_currency)
|
40
|
+
default_variant_price.compare_at_amount.present? && (default_variant_price.compare_at_amount > default_variant_price.amount)
|
41
|
+
end
|
42
|
+
|
38
43
|
def used_variants_options(variants, product)
|
39
44
|
variants_option_types_presenter(variants, product).options
|
40
45
|
end
|
@@ -115,19 +120,39 @@ module Spree
|
|
115
120
|
).call.to_json
|
116
121
|
end
|
117
122
|
|
123
|
+
def product_relation_types
|
124
|
+
@product_relation_types ||= @product.respond_to?(:relation_types) ? @product.relation_types : []
|
125
|
+
end
|
126
|
+
|
127
|
+
def product_relations_by_type(relation_type)
|
128
|
+
return [] if product_relation_types.none? || !@product.respond_to?(:relations)
|
129
|
+
|
130
|
+
product_ids = @product.relations.where(relation_type: relation_type).pluck(:related_to_id).uniq
|
131
|
+
|
132
|
+
return [] if product_ids.empty?
|
133
|
+
|
134
|
+
Spree::Product.
|
135
|
+
available.not_discontinued.distinct.
|
136
|
+
where(id: product_ids).
|
137
|
+
includes(
|
138
|
+
:tax_category,
|
139
|
+
master: [
|
140
|
+
:prices,
|
141
|
+
{ images: { attachment_attachment: :blob } },
|
142
|
+
]
|
143
|
+
).
|
144
|
+
limit(Spree::Config[:products_per_page])
|
145
|
+
end
|
146
|
+
|
118
147
|
def related_products
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
images: { attachment_attachment: :blob },
|
128
|
-
]
|
129
|
-
).
|
130
|
-
limit(Spree::Config[:products_per_page])
|
148
|
+
ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller)
|
149
|
+
ProductsHelper#related_products is deprecated and will be removed in Spree 5.0.
|
150
|
+
Please use ProductsHelper#relations from now on.
|
151
|
+
DEPRECATION
|
152
|
+
|
153
|
+
return [] unless @product.respond_to?(:has_related_products?)
|
154
|
+
|
155
|
+
@related_products ||= relations_by_type('related_products')
|
131
156
|
end
|
132
157
|
|
133
158
|
def product_available_in_currency?
|
@@ -69,7 +69,7 @@ module Spree
|
|
69
69
|
preference :credit_to_new_allocation, :boolean, default: false
|
70
70
|
|
71
71
|
# Multi store configurations
|
72
|
-
preference :show_store_selector, :boolean, default:
|
72
|
+
preference :show_store_selector, :boolean, default: true
|
73
73
|
|
74
74
|
# searcher_class allows spree extension writers to provide their own Search class
|
75
75
|
def searcher_class
|
data/app/models/spree/image.rb
CHANGED
@@ -15,13 +15,13 @@ module Spree
|
|
15
15
|
width, height = size.chop.split('x')
|
16
16
|
|
17
17
|
{
|
18
|
-
url: polymorphic_path(attachment.variant(
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
18
|
+
url: polymorphic_path(attachment.variant(
|
19
|
+
gravity: 'center',
|
20
|
+
resize: size,
|
21
|
+
extent: size,
|
22
|
+
background: 'snow2',
|
23
|
+
quality: 80
|
24
|
+
), only_path: true),
|
25
25
|
width: width,
|
26
26
|
height: height
|
27
27
|
}
|
@@ -35,13 +35,13 @@ module Spree
|
|
35
35
|
width, height = size.chop.split('x')
|
36
36
|
|
37
37
|
{
|
38
|
-
url: polymorphic_path(attachment.variant(
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
38
|
+
url: polymorphic_path(attachment.variant(
|
39
|
+
gravity: 'center',
|
40
|
+
resize: size,
|
41
|
+
extent: size,
|
42
|
+
background: 'snow2',
|
43
|
+
quality: 80
|
44
|
+
), only_path: true),
|
45
45
|
size: size,
|
46
46
|
width: width,
|
47
47
|
height: height
|
data/app/models/spree/product.rb
CHANGED
@@ -160,7 +160,7 @@ module Spree
|
|
160
160
|
#
|
161
161
|
# @return [Spree::Variant]
|
162
162
|
def default_variant
|
163
|
-
Rails.cache.fetch(default_variant_cache_key) do
|
163
|
+
@default_variant ||= Rails.cache.fetch(default_variant_cache_key) do
|
164
164
|
if Spree::Config[:track_inventory_levels] && variants.in_stock_or_backorderable.any?
|
165
165
|
variants.in_stock_or_backorderable.first
|
166
166
|
else
|
@@ -172,11 +172,11 @@ module Spree
|
|
172
172
|
# Returns default Variant ID for Product
|
173
173
|
# @return [Integer]
|
174
174
|
def default_variant_id
|
175
|
-
default_variant.id
|
175
|
+
@default_variant_id ||= default_variant.id
|
176
176
|
end
|
177
177
|
|
178
178
|
def tax_category
|
179
|
-
super || TaxCategory.find_by(is_default: true)
|
179
|
+
@tax_category ||= super || TaxCategory.find_by(is_default: true)
|
180
180
|
end
|
181
181
|
|
182
182
|
# Adding properties and option types on creation based on a chosen prototype
|
@@ -288,11 +288,11 @@ module Spree
|
|
288
288
|
end
|
289
289
|
|
290
290
|
def total_on_hand
|
291
|
-
if any_variants_not_track_inventory?
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
291
|
+
@total_on_hand ||= if any_variants_not_track_inventory?
|
292
|
+
Float::INFINITY
|
293
|
+
else
|
294
|
+
stock_items.sum(:count_on_hand)
|
295
|
+
end
|
296
296
|
end
|
297
297
|
|
298
298
|
# Master variant may be deleted (i.e. when the product is deleted)
|
@@ -303,14 +303,11 @@ module Spree
|
|
303
303
|
end
|
304
304
|
|
305
305
|
def brand
|
306
|
-
taxons.joins(:taxonomy).find_by(spree_taxonomies: { name: Spree.t(:taxonomy_brands_name) })
|
306
|
+
@brand ||= taxons.joins(:taxonomy).find_by(spree_taxonomies: { name: Spree.t(:taxonomy_brands_name) })
|
307
307
|
end
|
308
308
|
|
309
309
|
def category
|
310
|
-
taxons.joins(:taxonomy).
|
311
|
-
where(spree_taxonomies: { name: Spree.t(:taxonomy_categories_name) }).
|
312
|
-
order(depth: :desc).
|
313
|
-
first
|
310
|
+
@category ||= taxons.joins(:taxonomy).order(depth: :desc).find_by(spree_taxonomies: { name: Spree.t(:taxonomy_categories_name) })
|
314
311
|
end
|
315
312
|
|
316
313
|
private
|
@@ -440,12 +437,12 @@ module Spree
|
|
440
437
|
end
|
441
438
|
|
442
439
|
def taxon_and_ancestors
|
443
|
-
taxons.map(&:self_and_ancestors).flatten.uniq
|
440
|
+
@taxon_and_ancestors ||= taxons.map(&:self_and_ancestors).flatten.uniq
|
444
441
|
end
|
445
442
|
|
446
443
|
# Get the taxonomy ids of all taxons assigned to this product and their ancestors.
|
447
444
|
def taxonomy_ids
|
448
|
-
taxon_and_ancestors.map(&:taxonomy_id).flatten.uniq
|
445
|
+
@taxonomy_ids ||= taxon_and_ancestors.map(&:taxonomy_id).flatten.uniq
|
449
446
|
end
|
450
447
|
|
451
448
|
# Iterate through this products taxons and taxonomies and touch their timestamps in a batch
|
@@ -31,7 +31,7 @@ module Spree
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def actionable?(line_item)
|
34
|
-
product_id = line_item.
|
34
|
+
product_id = line_item.product_id
|
35
35
|
option_values_ids = line_item.variant.option_value_ids
|
36
36
|
eligible_product_ids = preferred_eligible_values.keys
|
37
37
|
eligible_value_ids = preferred_eligible_values[product_id]
|
data/app/models/spree/store.rb
CHANGED
@@ -43,28 +43,39 @@ module Spree
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
+
def self.available_locales
|
47
|
+
Rails.cache.fetch('stores_available_locales') do
|
48
|
+
Spree::Store.all.map(&:supported_locales_list).flatten.uniq
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
46
52
|
def supported_currencies_list
|
47
|
-
(read_attribute(:supported_currencies).to_s.split(',') << default_currency).map(&:to_s).map do |code|
|
53
|
+
@supported_currencies_list ||= (read_attribute(:supported_currencies).to_s.split(',') << default_currency).map(&:to_s).map do |code|
|
48
54
|
::Money::Currency.find(code.strip)
|
49
55
|
end.uniq.compact
|
50
56
|
end
|
51
57
|
|
58
|
+
def supported_locales_list
|
59
|
+
# TODO: add support of multiple supported languages to a single Store
|
60
|
+
@supported_locales_list ||= [default_locale].compact.uniq
|
61
|
+
end
|
62
|
+
|
52
63
|
def unique_name
|
53
|
-
"#{name} (#{code})"
|
64
|
+
@unique_name ||= "#{name} (#{code})"
|
54
65
|
end
|
55
66
|
|
56
67
|
def formatted_url
|
57
68
|
return if url.blank?
|
58
69
|
|
59
|
-
if url.match(/http:\/\/|https:\/\//)
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
70
|
+
@formatted_url ||= if url.match(/http:\/\/|https:\/\//)
|
71
|
+
url
|
72
|
+
else
|
73
|
+
Rails.env.development? ? "http://#{url}" : "https://#{url}"
|
74
|
+
end
|
64
75
|
end
|
65
76
|
|
66
77
|
def countries_available_for_checkout
|
67
|
-
checkout_zone_or_default.try(:country_list) || Spree::Country.all
|
78
|
+
@countries_available_for_checkout ||= checkout_zone_or_default.try(:country_list) || Spree::Country.all
|
68
79
|
end
|
69
80
|
|
70
81
|
def states_available_for_checkout(country)
|
@@ -72,7 +83,7 @@ module Spree
|
|
72
83
|
end
|
73
84
|
|
74
85
|
def checkout_zone_or_default
|
75
|
-
checkout_zone || Spree::Zone.default_checkout_zone
|
86
|
+
@checkout_zone_or_default ||= checkout_zone || Spree::Zone.default_checkout_zone
|
76
87
|
end
|
77
88
|
|
78
89
|
private
|
@@ -94,6 +105,7 @@ module Spree
|
|
94
105
|
|
95
106
|
def clear_cache
|
96
107
|
Rails.cache.delete('default_store')
|
108
|
+
Rails.cache.delete('stores_available_locales')
|
97
109
|
end
|
98
110
|
end
|
99
111
|
end
|
data/app/models/spree/variant.rb
CHANGED
@@ -123,15 +123,15 @@ module Spree
|
|
123
123
|
end
|
124
124
|
|
125
125
|
def tax_category
|
126
|
-
if self[:tax_category_id].nil?
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
126
|
+
@tax_category ||= if self[:tax_category_id].nil?
|
127
|
+
product.tax_category
|
128
|
+
else
|
129
|
+
Spree::TaxCategory.find(self[:tax_category_id])
|
130
|
+
end
|
131
131
|
end
|
132
132
|
|
133
133
|
def options_text
|
134
|
-
Spree::Variants::OptionsPresenter.new(self).to_sentence
|
134
|
+
@options_text ||= Spree::Variants::OptionsPresenter.new(self).to_sentence
|
135
135
|
end
|
136
136
|
|
137
137
|
# Default to master name
|
@@ -226,7 +226,7 @@ module Spree
|
|
226
226
|
end
|
227
227
|
|
228
228
|
def compare_at_price
|
229
|
-
price_in(cost_currency).try(:compare_at_amount)
|
229
|
+
@compare_at_price ||= price_in(cost_currency).try(:compare_at_amount)
|
230
230
|
end
|
231
231
|
|
232
232
|
def name_and_sku
|
@@ -2,6 +2,7 @@ module Spree
|
|
2
2
|
class VariantPresenter
|
3
3
|
include Rails.application.routes.url_helpers
|
4
4
|
include Spree::BaseHelper
|
5
|
+
include Spree::ProductsHelper
|
5
6
|
|
6
7
|
attr_reader :current_currency, :current_price_options, :current_store
|
7
8
|
|
@@ -19,7 +20,7 @@ module Spree
|
|
19
20
|
display_price: display_price(variant),
|
20
21
|
price: variant.price_in(current_currency),
|
21
22
|
display_compare_at_price: display_compare_at_price(variant),
|
22
|
-
should_display_compare_at_price: should_display_compare_at_price(variant),
|
23
|
+
should_display_compare_at_price: should_display_compare_at_price?(variant),
|
23
24
|
is_product_available_in_currency: @is_product_available_in_currency,
|
24
25
|
backorderable: backorderable?(variant),
|
25
26
|
in_stock: in_stock?(variant),
|
@@ -75,9 +76,5 @@ module Spree
|
|
75
76
|
purchasable: variant.purchasable?
|
76
77
|
}
|
77
78
|
end
|
78
|
-
|
79
|
-
def should_display_compare_at_price(variant)
|
80
|
-
variant.compare_at_price.present? && variant.compare_at_price > variant.price
|
81
|
-
end
|
82
79
|
end
|
83
80
|
end
|
File without changes
|
File without changes
|
@@ -20,7 +20,7 @@
|
|
20
20
|
</td>
|
21
21
|
<td class="align-right">
|
22
22
|
<span class="f-fallback purchase_item_price">
|
23
|
-
<%= line_item.quantity %> x <%= line_item.single_money
|
23
|
+
<%= line_item.quantity %> x <%= line_item.single_money %><br>
|
24
24
|
<%= line_item.display_amount %>
|
25
25
|
</span>
|
26
26
|
</td>
|
data/config/locales/en.yml
CHANGED
@@ -663,7 +663,6 @@ en:
|
|
663
663
|
jackets_and_coats: JACKET & COASTS
|
664
664
|
new_collection: NEW COLLECTION
|
665
665
|
special_offers: SPECIAL OFFERS
|
666
|
-
summer_2019: SUMMER 2019
|
667
666
|
channel: Channel
|
668
667
|
charged: Charged
|
669
668
|
checkout: Checkout
|
@@ -760,38 +759,10 @@ en:
|
|
760
759
|
date: Date
|
761
760
|
date_completed: Date Completed
|
762
761
|
date_picker:
|
763
|
-
am: 'AM'
|
764
762
|
first_day: 0
|
765
763
|
format: ! '%Y/%m/%d'
|
766
|
-
hourAriaLabel: 'Hour'
|
767
764
|
js_format: Y/m/d
|
768
765
|
js_date_time: Y/m/d - H:i
|
769
|
-
minuteAriaLabel: 'Minute'
|
770
|
-
pm: 'PM'
|
771
|
-
rangeSeparator: ' to '
|
772
|
-
scrollTitle: 'Scroll to increment'
|
773
|
-
toggleTitle: 'Click to toggle'
|
774
|
-
weekAbbreviation: 'Wk'
|
775
|
-
yearAriaLabel: 'Year'
|
776
|
-
sun: 'Sun'
|
777
|
-
mon: 'Mon'
|
778
|
-
tue: 'Tue'
|
779
|
-
wed: 'Wed'
|
780
|
-
thu: 'Thu'
|
781
|
-
fri: 'Fri'
|
782
|
-
sat: 'Sat'
|
783
|
-
lh_jan: 'January'
|
784
|
-
lh_feb: 'February'
|
785
|
-
lh_mar: 'March'
|
786
|
-
lh_apr: 'April'
|
787
|
-
lh_may: 'May'
|
788
|
-
lh_jun: 'June'
|
789
|
-
lh_jul: 'July'
|
790
|
-
lh_aug: 'August'
|
791
|
-
lh_sep: 'September'
|
792
|
-
lh_oct: 'October'
|
793
|
-
lh_nov: 'November'
|
794
|
-
lh_dec: 'December'
|
795
766
|
date_range: Date Range
|
796
767
|
default: Default
|
797
768
|
default_country_cannot_be_deleted: Default country cannot be deleted
|
@@ -926,24 +897,6 @@ en:
|
|
926
897
|
hide_from_subcategories_nav: Hide from subcategories navigation
|
927
898
|
home: Home
|
928
899
|
home_page: homepage
|
929
|
-
homepage:
|
930
|
-
bestsellers: BESTSELLERS
|
931
|
-
fashion_trends: FASHION TRENDS
|
932
|
-
fashion_trends_note: Want to rock this season’s hottest trend in style? These are the top fashion from Summer 2020 Fashion Weeks that are coming our way this season.
|
933
|
-
men: MEN
|
934
|
-
new: NEW
|
935
|
-
new_collection: NEW COLLECTION
|
936
|
-
read_more: READ MORE
|
937
|
-
shoes: SHOES
|
938
|
-
shop_now: SHOP NOW
|
939
|
-
sportswear: SPORTSWEAR
|
940
|
-
streetstyle: STREETSTYLE
|
941
|
-
summer_2020: Summer 2020
|
942
|
-
summer_collection: Summer Collection
|
943
|
-
summer_sale: SUMMER SALE
|
944
|
-
trending: TRENDING
|
945
|
-
up_to_60: UP TO 60%
|
946
|
-
women: WOMEN
|
947
900
|
help_center: Help Center
|
948
901
|
i18n:
|
949
902
|
available_locales: Available Locales
|
data/config/routes.rb
CHANGED
data/db/default/spree/stores.rb
CHANGED
@@ -11,6 +11,7 @@ else
|
|
11
11
|
s.customer_support_email = 'support@example.com'
|
12
12
|
s.default_currency = 'USD'
|
13
13
|
s.default_country_id = Spree::Config[:default_country_id]
|
14
|
+
s.default_locale = I18n.locale
|
14
15
|
s.seo_title = 'Spree Commerce Demo Shop'
|
15
16
|
s.meta_description = 'This is the new Spree UX DEMO | OVERVIEW: http://bit.ly/new-spree-ux | DOCS: http://bit.ly/spree-ux-customization-docs | CONTACT: https://spreecommerce.org/contact/'
|
16
17
|
s.facebook = 'spreecommerce'
|
@@ -18,12 +18,12 @@ default:
|
|
18
18
|
:url: /t/women/jackets-and-coats
|
19
19
|
promo_banners:
|
20
20
|
- subtitle: New collection
|
21
|
-
title: Summer
|
22
|
-
url: /t/new-collection/summer-
|
21
|
+
title: Summer 2021
|
22
|
+
url: /t/new-collection/summer-2021
|
23
23
|
image: 'meganav/promo_banner_left-first-category.jpg'
|
24
24
|
- subtitle: Special Offers
|
25
25
|
title: Get up to 30% off
|
26
|
-
url: /t/special-offers/30-off
|
26
|
+
url: /t/special-offers/30-percent-off
|
27
27
|
image: 'meganav/promo_banner_right-first-category.jpg'
|
28
28
|
- title: Men
|
29
29
|
subtitle: Categories
|
@@ -39,12 +39,12 @@ default:
|
|
39
39
|
:url: /t/men/jackets-and-coats
|
40
40
|
promo_banners:
|
41
41
|
- subtitle: New collection
|
42
|
-
title: Summer
|
43
|
-
url: /t/new-collection/summer-
|
42
|
+
title: Summer 2021
|
43
|
+
url: /t/new-collection/summer-2021
|
44
44
|
image: 'meganav/promo_banner_left-second-category.jpg'
|
45
45
|
- subtitle: Special Offers
|
46
46
|
title: Get up to 30% off
|
47
|
-
url: /t/special-offers/30-off
|
47
|
+
url: /t/special-offers/30-percent-off
|
48
48
|
image: 'meganav/promo_banner_right-second-category.jpg'
|
49
49
|
- title: Sportswear
|
50
50
|
subtitle: Categories
|
@@ -58,10 +58,10 @@ default:
|
|
58
58
|
:url: /t/sportswear/pants
|
59
59
|
promo_banners:
|
60
60
|
- subtitle: New collection
|
61
|
-
title: Summer
|
62
|
-
url: /t/new-collection/summer-
|
61
|
+
title: Summer 2021
|
62
|
+
url: /t/new-collection/summer-2021
|
63
63
|
image: 'meganav/promo_banner_left-third-category.jpg'
|
64
64
|
- subtitle: Special Offers
|
65
65
|
title: Get up to 30% off
|
66
|
-
url: /t/special-offers/30-off
|
66
|
+
url: /t/special-offers/30-percent-off
|
67
67
|
image: 'meganav/promo_banner_right-third-category.jpg'
|
data/lib/spree/core.rb
CHANGED
@@ -105,4 +105,5 @@ require 'spree/core/controller_helpers/order'
|
|
105
105
|
require 'spree/core/controller_helpers/search'
|
106
106
|
require 'spree/core/controller_helpers/store'
|
107
107
|
require 'spree/core/controller_helpers/strong_parameters'
|
108
|
-
require 'spree/core/controller_helpers/
|
108
|
+
require 'spree/core/controller_helpers/locale'
|
109
|
+
require 'spree/core/controller_helpers/currency'
|
@@ -76,7 +76,9 @@ module Spree
|
|
76
76
|
redirect_to spree.forbidden_path
|
77
77
|
else
|
78
78
|
store_location
|
79
|
-
if
|
79
|
+
if request.fullpath.match(Spree.admin_path) && defined?(spree.admin_login_path)
|
80
|
+
redirect_to spree.admin_login_path
|
81
|
+
elsif respond_to?(:spree_login_path)
|
80
82
|
redirect_to spree_login_path
|
81
83
|
elsif spree.respond_to?(:root_path)
|
82
84
|
redirect_to spree.root_path
|
@@ -10,8 +10,6 @@ module Spree
|
|
10
10
|
|
11
11
|
layout :get_layout
|
12
12
|
|
13
|
-
before_action :set_user_language
|
14
|
-
|
15
13
|
protected
|
16
14
|
|
17
15
|
# can be used in views as well as controllers.
|
@@ -43,12 +41,12 @@ module Spree
|
|
43
41
|
private
|
44
42
|
|
45
43
|
def set_user_language
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
44
|
+
ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller)
|
45
|
+
ControllerHelpers::Common#set_user_language is deprecated and will be removed in Spree 5.0.
|
46
|
+
Please use `before_action :set_locale` instead
|
47
|
+
DEPRECATION
|
48
|
+
|
49
|
+
set_locale
|
52
50
|
end
|
53
51
|
|
54
52
|
# Returns which layout to render.
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Spree
|
2
|
+
module Core
|
3
|
+
module ControllerHelpers
|
4
|
+
module Currency
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
helper_method :supported_currencies
|
9
|
+
helper_method :supported_currencies_for_all_stores
|
10
|
+
helper_method :current_currency
|
11
|
+
helper_method :supported_currency?
|
12
|
+
end
|
13
|
+
|
14
|
+
def current_currency
|
15
|
+
# session support was previously in SpreeMultiCurrency so we would like
|
16
|
+
# to keep it for now
|
17
|
+
@current_currency ||= if defined?(session) && session.key?(:currency) && supported_currency?(session[:currency])
|
18
|
+
session[:currency]
|
19
|
+
elsif params[:currency].present? && supported_currency?(params[:currency])
|
20
|
+
params[:currency]
|
21
|
+
else
|
22
|
+
current_store.default_currency
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def supported_currencies
|
27
|
+
@supported_currencies ||= current_store.supported_currencies_list
|
28
|
+
end
|
29
|
+
|
30
|
+
def supported_currencies_for_all_stores
|
31
|
+
@supported_currencies_for_all_stores ||= begin
|
32
|
+
(
|
33
|
+
Spree::Store.pluck(:supported_currencies).map { |c| c&.split(',') }.flatten + Spree::Store.pluck(:default_currency)
|
34
|
+
).
|
35
|
+
compact.uniq.map { |code| ::Money::Currency.find(code.strip) }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def supported_currency?(currency_iso_code)
|
40
|
+
supported_currencies.map(&:iso_code).include?(currency_iso_code)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Spree
|
2
|
+
module Core
|
3
|
+
module ControllerHelpers
|
4
|
+
module Locale
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
before_action :set_locale
|
9
|
+
|
10
|
+
helper_method :supported_locales
|
11
|
+
helper_method :supported_locales_for_all_stores
|
12
|
+
helper_method :current_locale
|
13
|
+
helper_method :supported_locale?
|
14
|
+
helper_method :available_locales
|
15
|
+
end
|
16
|
+
|
17
|
+
def set_locale
|
18
|
+
I18n.locale = current_locale
|
19
|
+
end
|
20
|
+
|
21
|
+
def current_locale
|
22
|
+
# session support was previously in SpreeI18n so we would like to keep it for now
|
23
|
+
# for easer upgrade
|
24
|
+
@current_locale ||= if defined?(session) && session.key?(:locale) && supported_locale?(session[:locale])
|
25
|
+
session[:locale]
|
26
|
+
elsif params[:locale].present? && supported_locale?(params[:locale])
|
27
|
+
params[:locale]
|
28
|
+
elsif respond_to?(:config_locale, true) && config_locale.present?
|
29
|
+
config_locale
|
30
|
+
else
|
31
|
+
current_store.default_locale || Rails.application.config.i18n.default_locale || I18n.default_locale
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def supported_locales
|
36
|
+
@supported_locales ||= current_store.supported_locales_list
|
37
|
+
end
|
38
|
+
|
39
|
+
def supported_locale?(locale_code)
|
40
|
+
supported_locales.include?(locale_code&.to_s)
|
41
|
+
end
|
42
|
+
|
43
|
+
def supported_locales_for_all_stores
|
44
|
+
@supported_locales_for_all_stores ||= (if defined?(SpreeI18n)
|
45
|
+
(SpreeI18n::Locale.all << :en).map(&:to_s)
|
46
|
+
else
|
47
|
+
[Rails.application.config.i18n.default_locale, I18n.locale, :en]
|
48
|
+
end).uniq.compact
|
49
|
+
end
|
50
|
+
|
51
|
+
def available_locales
|
52
|
+
Spree::Store.available_locales
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -5,26 +5,10 @@ module Spree
|
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
included do
|
8
|
-
helper_method :supported_currencies
|
9
|
-
helper_method :current_currency
|
10
8
|
helper_method :current_store
|
11
9
|
helper_method :current_price_options
|
12
10
|
end
|
13
11
|
|
14
|
-
def current_currency
|
15
|
-
if defined?(session) && session.key?(:currency) && supported_currencies.map(&:iso_code).include?(session[:currency])
|
16
|
-
session[:currency]
|
17
|
-
elsif params[:currency].present? && supported_currencies.map(&:iso_code).include?(params[:currency])
|
18
|
-
params[:currency]
|
19
|
-
else
|
20
|
-
current_store.default_currency
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def supported_currencies
|
25
|
-
current_store.supported_currencies_list
|
26
|
-
end
|
27
|
-
|
28
12
|
def current_store
|
29
13
|
@current_store ||= Spree::Store.current(request.env['SERVER_NAME'])
|
30
14
|
end
|
data/lib/spree/core/version.rb
CHANGED
@@ -20,8 +20,8 @@ FactoryBot.define do
|
|
20
20
|
product_1 = create(:product)
|
21
21
|
product_2 = create(:product)
|
22
22
|
|
23
|
-
stock_location.stock_items.where(variant_id: product_1.
|
24
|
-
stock_location.stock_items.where(variant_id: product_2.
|
23
|
+
stock_location.stock_items.where(variant_id: product_1.master_id).first.adjust_count_on_hand(10)
|
24
|
+
stock_location.stock_items.where(variant_id: product_2.master_id).first.adjust_count_on_hand(20)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.0.
|
4
|
+
version: 4.2.0.rc5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Schofield
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-02-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemerchant
|
@@ -447,6 +447,7 @@ files:
|
|
447
447
|
- app/assets/images/noimage/small.png
|
448
448
|
- app/assets/javascripts/spree.js
|
449
449
|
- app/controllers/spree/base_controller.rb
|
450
|
+
- app/controllers/spree/errors_controller.rb
|
450
451
|
- app/finders/spree/addresses/find.rb
|
451
452
|
- app/finders/spree/base_finder.rb
|
452
453
|
- app/finders/spree/countries/find.rb
|
@@ -459,6 +460,7 @@ files:
|
|
459
460
|
- app/finders/spree/variants/option_types_finder.rb
|
460
461
|
- app/finders/spree/variants/visible_finder.rb
|
461
462
|
- app/helpers/spree/base_helper.rb
|
463
|
+
- app/helpers/spree/locale_helper.rb
|
462
464
|
- app/helpers/spree/mail_helper.rb
|
463
465
|
- app/helpers/spree/products_helper.rb
|
464
466
|
- app/mailers/spree/base_mailer.rb
|
@@ -688,6 +690,8 @@ files:
|
|
688
690
|
- app/validators/db_maximum_length_validator.rb
|
689
691
|
- app/validators/email_validator.rb
|
690
692
|
- app/views/layouts/spree/base_mailer.html.erb
|
693
|
+
- app/views/spree/errors/forbidden.html.erb
|
694
|
+
- app/views/spree/errors/unauthorized.html.erb
|
691
695
|
- app/views/spree/order_mailer/cancel_email.html.erb
|
692
696
|
- app/views/spree/order_mailer/cancel_email.text.erb
|
693
697
|
- app/views/spree/order_mailer/confirm_email.html.erb
|
@@ -1014,6 +1018,7 @@ files:
|
|
1014
1018
|
- db/migrate/20210114182625_create_spree_payment_methods_stores.rb
|
1015
1019
|
- db/migrate/20210114220232_migrate_data_payment_methods_stores.rb
|
1016
1020
|
- db/migrate/20210117112551_remove_store_id_from_spree_payment_methods.rb
|
1021
|
+
- db/migrate/20210120142527_ensure_default_locale_in_spree_stores.rb
|
1017
1022
|
- db/seeds.rb
|
1018
1023
|
- lib/friendly_id/slug_rails5_patch.rb
|
1019
1024
|
- lib/generators/spree/custom_user/custom_user_generator.rb
|
@@ -1049,7 +1054,8 @@ files:
|
|
1049
1054
|
- lib/spree/core/components.rb
|
1050
1055
|
- lib/spree/core/controller_helpers/auth.rb
|
1051
1056
|
- lib/spree/core/controller_helpers/common.rb
|
1052
|
-
- lib/spree/core/controller_helpers/
|
1057
|
+
- lib/spree/core/controller_helpers/currency.rb
|
1058
|
+
- lib/spree/core/controller_helpers/locale.rb
|
1053
1059
|
- lib/spree/core/controller_helpers/order.rb
|
1054
1060
|
- lib/spree/core/controller_helpers/search.rb
|
1055
1061
|
- lib/spree/core/controller_helpers/store.rb
|
@@ -1164,9 +1170,9 @@ licenses:
|
|
1164
1170
|
- BSD-3-Clause
|
1165
1171
|
metadata:
|
1166
1172
|
bug_tracker_uri: https://github.com/spree/spree/issues
|
1167
|
-
changelog_uri: https://github.com/spree/spree/releases/tag/v4.2.0.
|
1173
|
+
changelog_uri: https://github.com/spree/spree/releases/tag/v4.2.0.rc5
|
1168
1174
|
documentation_uri: https://guides.spreecommerce.org/
|
1169
|
-
source_code_uri: https://github.com/spree/spree/tree/v4.2.0.
|
1175
|
+
source_code_uri: https://github.com/spree/spree/tree/v4.2.0.rc5
|
1170
1176
|
post_install_message:
|
1171
1177
|
rdoc_options: []
|
1172
1178
|
require_paths:
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
module Core
|
3
|
-
module ControllerHelpers
|
4
|
-
module CurrencyHelpers
|
5
|
-
def self.included(receiver)
|
6
|
-
receiver.send :helper_method, :supported_currencies
|
7
|
-
end
|
8
|
-
|
9
|
-
def supported_currencies
|
10
|
-
current_store.supported_currencies_list
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|