spree_core 4.7.2 → 4.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/app/finders/spree/taxons/find.rb +7 -3
- data/app/models/concerns/spree/named_type.rb +1 -1
- data/app/models/concerns/spree/product_scopes.rb +19 -19
- data/app/models/concerns/spree/user_address.rb +4 -2
- data/app/models/spree/address.rb +2 -21
- data/app/models/spree/asset.rb +2 -2
- data/app/models/spree/calculator/default_tax.rb +1 -1
- data/app/models/spree/cms_page.rb +3 -3
- data/app/models/spree/cms_section.rb +1 -1
- data/app/models/spree/country.rb +0 -26
- data/app/models/spree/credit_card.rb +5 -3
- data/app/models/spree/customer_return.rb +3 -3
- data/app/models/spree/digital.rb +1 -1
- data/app/models/spree/digital_link.rb +1 -1
- data/app/models/spree/image.rb +2 -2
- data/app/models/spree/inventory_unit.rb +1 -1
- data/app/models/spree/legacy_user.rb +3 -3
- data/app/models/spree/line_item.rb +2 -2
- data/app/models/spree/menu.rb +2 -2
- data/app/models/spree/menu_item.rb +1 -1
- data/app/models/spree/option_type.rb +6 -6
- data/app/models/spree/option_value.rb +5 -5
- data/app/models/spree/order.rb +9 -7
- data/app/models/spree/payment.rb +4 -4
- data/app/models/spree/payment_capture_event.rb +1 -1
- data/app/models/spree/payment_method.rb +1 -1
- data/app/models/spree/payment_source.rb +1 -1
- data/app/models/spree/price.rb +4 -2
- data/app/models/spree/product.rb +30 -19
- data/app/models/spree/product_property.rb +5 -3
- data/app/models/spree/promotion.rb +3 -3
- data/app/models/spree/property.rb +8 -6
- data/app/models/spree/prototype.rb +2 -2
- data/app/models/spree/refund.rb +2 -2
- data/app/models/spree/reimbursement.rb +2 -2
- data/app/models/spree/return_authorization.rb +2 -2
- data/app/models/spree/return_item.rb +1 -1
- data/app/models/spree/role.rb +1 -1
- data/app/models/spree/shipment.rb +4 -4
- data/app/models/spree/shipping_category.rb +2 -2
- data/app/models/spree/shipping_method.rb +2 -2
- data/app/models/spree/stock/estimator.rb +1 -1
- data/app/models/spree/stock_item.rb +3 -3
- data/app/models/spree/stock_location.rb +7 -2
- data/app/models/spree/stock_movement.rb +1 -1
- data/app/models/spree/stock_transfer.rb +4 -4
- data/app/models/spree/store.rb +3 -5
- data/app/models/spree/store_credit.rb +3 -3
- data/app/models/spree/store_favicon_image.rb +11 -2
- data/app/models/spree/tax_category.rb +1 -1
- data/app/models/spree/tax_rate.rb +1 -1
- data/app/models/spree/taxon.rb +23 -7
- data/app/models/spree/taxon_image.rb +2 -2
- data/app/models/spree/taxonomy.rb +5 -5
- data/app/models/spree/variant.rb +11 -6
- data/app/models/spree/wished_item.rb +1 -1
- data/app/models/spree/wishlist.rb +2 -2
- data/app/models/spree/zone.rb +2 -2
- data/app/services/spree/addresses/update.rb +1 -0
- data/app/services/spree/seeds/all.rb +15 -13
- data/app/services/spree/seeds/stores.rb +2 -2
- data/app/sorters/spree/products/sort.rb +1 -1
- data/config/initializers/mobility.rb +1 -0
- data/config/routes.rb +7 -8
- data/db/migrate/20210929090344_create_stock_item_stock_location_id_variant_id_coalesce_deleted_at_unique_index.rb +1 -28
- data/db/migrate/20230103144439_create_option_type_translations.rb +0 -1
- data/db/migrate/20230103151034_create_option_value_translations.rb +0 -1
- data/db/migrate/20230109084253_create_product_property_translations.rb +0 -1
- data/db/migrate/20230109105943_create_property_translations.rb +0 -2
- data/db/migrate/20230110142344_backfill_friendly_id_slug_locale.rb +2 -8
- data/db/migrate/20240303174340_fix_spree_stock_item_unique_index.rb +35 -0
- data/db/migrate/20240514105216_add_weight_and_dimension_units_to_spree_variants.rb +6 -0
- data/lib/generators/spree/custom_authentication/custom_authentication_generator.rb +23 -0
- data/lib/generators/spree/{custom_user → custom_authentication}/templates/authentication_helpers.rb.tt +1 -14
- data/lib/generators/spree/custom_user/custom_user_generator.rb +3 -8
- data/lib/generators/spree/custom_user/templates/current_user_helpers.rb.tt +15 -0
- data/lib/generators/spree/custom_user/templates/migration.rb.tt +2 -2
- data/lib/generators/spree/dummy/dummy_generator.rb +1 -6
- data/lib/generators/spree/dummy/templates/rails/database.yml +19 -21
- data/lib/generators/spree/dummy/templates/rails/test.rb +1 -1
- data/lib/generators/spree/install/templates/config/initializers/spree.rb +25 -0
- data/lib/spree/core/configuration.rb +11 -25
- data/lib/spree/core/controller_helpers/locale.rb +5 -1
- data/lib/spree/core/engine.rb +4 -1
- data/lib/spree/core/preferences/runtime_configuration.rb +43 -0
- data/lib/spree/core/product_duplicator.rb +2 -0
- data/lib/spree/core/product_filters.rb +9 -2
- data/lib/spree/core/runtime_configuration.rb +9 -0
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core/webhooks.rb +13 -0
- data/lib/spree/core.rb +7 -0
- data/lib/spree/money.rb +38 -5
- data/lib/spree/testing_support/authorization_helpers.rb +3 -1
- data/lib/spree/testing_support/common_rake.rb +7 -18
- data/spree_core.gemspec +7 -7
- metadata +47 -50
- data/db/migrate/20220715120222_change_product_name_null_to_true.rb +0 -5
- data/db/migrate/20220718100948_change_taxon_name_null_to_true.rb +0 -5
- data/db/migrate/20220804073928_transfer_data_to_translatable_tables.rb +0 -66
- data/db/migrate/20230109094907_transfer_options_data_to_translatable_tables.rb +0 -58
- data/db/migrate/20230109110840_transfer_property_data_to_translatable_tables.rb +0 -59
- data/db/migrate/20230111122511_transfer_product_and_taxon_data_to_translatable_tables.rb +0 -82
- data/db/migrate/20230117120430_allow_null_taxonomy_name.rb +0 -5
- data/db/migrate/20230117121303_transfer_taxonomy_data_to_translatable_tables.rb +0 -11
- data/db/migrate/20230210142849_transfer_store_data_to_translatable_tables.rb +0 -11
- data/db/migrate/20230514162157_add_index_on_locale_and_permalink_to_spree_taxons.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb9614d2e37d1c4c04ad71985912a54e12c579ba21266bbec33d95d383bf03f4
|
4
|
+
data.tar.gz: 7cc25cd0d5e067d97c30a9932cde2a1e02cc3826ba37d98ec14aa6ad5cd8f6ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e15d6b8da8503742847b455d084c6fd067fde3fc613605707f6c576a9e169cd9b410e2d6755554f2eef05fb622f0b5dd01533372bacc4b9d2f57407f45dac8e
|
7
|
+
data.tar.gz: 02e24962d02e6c6665c9d9a8292b9365353fc08170dd7c0697cf6d0234a4d2b22d0b61e0e6d035c2a4ec3f4c6d6b5eb453ae0a5dffae3739e7382ed83c80645d
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2007-
|
1
|
+
Copyright (c) 2007-2024, Spree Commerce, Inc., Spark Solutuons Sp. z o.o. and other contributors
|
2
2
|
All rights reserved.
|
3
3
|
|
4
4
|
Redistribution and use in source and binary forms, with or without modification,
|
@@ -65,9 +65,13 @@ module Spree
|
|
65
65
|
def by_parent_permalink(taxons)
|
66
66
|
return taxons unless parent_permalink?
|
67
67
|
|
68
|
-
|
69
|
-
|
70
|
-
|
68
|
+
if Spree.use_translations?
|
69
|
+
taxons.joins(:parent).
|
70
|
+
join_translation_table(Taxon, 'parents_spree_taxons').
|
71
|
+
where(["#{Taxon.translation_table_alias}.permalink = ?", parent_permalink])
|
72
|
+
else
|
73
|
+
taxons.joins(:parent).where(parent: { permalink: parent_permalink })
|
74
|
+
end
|
71
75
|
end
|
72
76
|
|
73
77
|
def by_taxonomy(taxons)
|
@@ -33,15 +33,15 @@ module Spree
|
|
33
33
|
|
34
34
|
def self.property_conditions(property)
|
35
35
|
properties_table = Property.table_name
|
36
|
-
|
36
|
+
|
37
37
|
case property
|
38
38
|
when Property then { "#{properties_table}.id" => property.id }
|
39
39
|
when Integer then { "#{properties_table}.id" => property }
|
40
40
|
else
|
41
41
|
if Property.column_for_attribute('id').type == :uuid
|
42
|
-
["#{
|
42
|
+
["#{properties_table}.name = ? OR #{properties_table}.id = ?", property, property]
|
43
43
|
else
|
44
|
-
{ "#{
|
44
|
+
{ "#{properties_table}.name" => property }
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -127,25 +127,29 @@ module Spree
|
|
127
127
|
|
128
128
|
# a scope that finds all products having property specified by name, object or id
|
129
129
|
add_search_scope :with_property do |property|
|
130
|
-
joins(:properties).
|
130
|
+
joins(:properties).where(property_conditions(property))
|
131
131
|
end
|
132
132
|
|
133
133
|
# a simple test for product with a certain property-value pairing
|
134
134
|
# note that it can test for properties with NULL values, but not for absent values
|
135
135
|
add_search_scope :with_property_value do |property, value|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
136
|
+
if Spree.use_translations?
|
137
|
+
joins(:properties).
|
138
|
+
join_translation_table(Property).
|
139
|
+
join_translation_table(ProductProperty).
|
140
|
+
where("#{ProductProperty.translation_table_alias}.value = ?", value).
|
141
|
+
where(property_conditions(property))
|
142
|
+
else
|
143
|
+
joins(:properties).
|
144
|
+
where("#{ProductProperty.table_name}.value = ?", value).
|
145
|
+
where(property_conditions(property))
|
146
|
+
end
|
141
147
|
end
|
142
148
|
|
143
149
|
add_search_scope :with_property_values do |property_filter_param, property_values|
|
144
150
|
joins(product_properties: :property).
|
145
|
-
|
146
|
-
|
147
|
-
where(Property.translation_table_alias => { filter_param: property_filter_param }).
|
148
|
-
where(ProductProperty.translation_table_alias => { filter_param: property_values.map(&:parameterize) })
|
151
|
+
where(Property.table_name => { filter_param: property_filter_param }).
|
152
|
+
where(ProductProperty.table_name => { filter_param: property_values.map(&:parameterize) })
|
149
153
|
end
|
150
154
|
|
151
155
|
add_search_scope :with_option do |option|
|
@@ -156,9 +160,7 @@ module Spree
|
|
156
160
|
elsif OptionType.column_for_attribute('id').type == :uuid
|
157
161
|
joins(:option_types).where(spree_option_types: { name: option }).or(Product.joins(:option_types).where(spree_option_types: { id: option }))
|
158
162
|
else
|
159
|
-
joins(:option_types).
|
160
|
-
join_translation_table(OptionType).
|
161
|
-
where(OptionType.translation_table_alias => { name: option })
|
163
|
+
joins(:option_types).where(OptionType.table_name => { name: option })
|
162
164
|
end
|
163
165
|
end
|
164
166
|
|
@@ -179,9 +181,7 @@ module Spree
|
|
179
181
|
|
180
182
|
group("#{Spree::Product.table_name}.id").
|
181
183
|
joins(variants_including_master: :option_values).
|
182
|
-
|
183
|
-
where(Spree::OptionValue.translation_table_alias => { name: value },
|
184
|
-
Spree::OptionValue.table_name => { option_type_id: option_type_id })
|
184
|
+
where(Spree::OptionValue.table_name => { name: value, option_type_id: option_type_id })
|
185
185
|
end
|
186
186
|
|
187
187
|
# Finds all products which have either:
|
@@ -5,11 +5,13 @@ module Spree
|
|
5
5
|
included do
|
6
6
|
belongs_to :bill_address, foreign_key: :bill_address_id, class_name: 'Spree::Address',
|
7
7
|
optional: true
|
8
|
-
|
8
|
+
alias_method :billing_address, :bill_address
|
9
|
+
alias_method :billing_address=, :bill_address=
|
9
10
|
|
10
11
|
belongs_to :ship_address, foreign_key: :ship_address_id, class_name: 'Spree::Address',
|
11
12
|
optional: true
|
12
|
-
|
13
|
+
alias_method :shipping_address, :ship_address
|
14
|
+
alias_method :shipping_address=, :ship_address=
|
13
15
|
|
14
16
|
accepts_nested_attributes_for :ship_address, :bill_address
|
15
17
|
|
data/app/models/spree/address.rb
CHANGED
@@ -2,8 +2,8 @@ module Spree
|
|
2
2
|
class Address < Spree::Base
|
3
3
|
require 'validates_zipcode'
|
4
4
|
|
5
|
-
include Metadata
|
6
|
-
if defined?(Spree::Webhooks)
|
5
|
+
include Spree::Metadata
|
6
|
+
if defined?(Spree::Webhooks::HasWebhooks)
|
7
7
|
include Spree::Webhooks::HasWebhooks
|
8
8
|
end
|
9
9
|
if defined?(Spree::Security::Addresses)
|
@@ -68,25 +68,6 @@ module Spree
|
|
68
68
|
self.whitelisted_ransackable_attributes = ADDRESS_FIELDS
|
69
69
|
self.whitelisted_ransackable_associations = %w[country state user]
|
70
70
|
|
71
|
-
def self.build_default
|
72
|
-
Spree::Deprecation.warn(<<-DEPRECATION, caller)
|
73
|
-
`Address#build_default` is deprecated and will be removed in Spree 5.0.
|
74
|
-
Please use standard rails `Address.new(country: current_store.default_country)`
|
75
|
-
DEPRECATION
|
76
|
-
new(country: Spree::Country.default)
|
77
|
-
end
|
78
|
-
|
79
|
-
def self.default(user = nil, kind = 'bill')
|
80
|
-
Spree::Deprecation.warn(<<-DEPRECATION, caller)
|
81
|
-
`Address#default` is deprecated and will be removed in Spree 5.0.
|
82
|
-
DEPRECATION
|
83
|
-
if user && user_address = user.public_send(:"#{kind}_address")
|
84
|
-
user_address.clone
|
85
|
-
else
|
86
|
-
build_default
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
71
|
def self.required_fields
|
91
72
|
Spree::Address.validators.map do |v|
|
92
73
|
v.is_a?(ActiveModel::Validations::PresenceValidator) ? v.attributes : []
|
data/app/models/spree/asset.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module Spree
|
2
2
|
class CmsPage < Base
|
3
|
-
include SingleStoreResource
|
4
|
-
include DisplayLink
|
3
|
+
include Spree::SingleStoreResource
|
4
|
+
include Spree::DisplayLink
|
5
5
|
|
6
|
-
if defined?(Spree::Webhooks)
|
6
|
+
if defined?(Spree::Webhooks::HasWebhooks)
|
7
7
|
include Spree::Webhooks::HasWebhooks
|
8
8
|
end
|
9
9
|
|
data/app/models/spree/country.rb
CHANGED
@@ -1,9 +1,5 @@
|
|
1
1
|
module Spree
|
2
2
|
class Country < Spree::Base
|
3
|
-
# we need to have this callback before any dependent: :destroy associations
|
4
|
-
# https://github.com/rails/rails/issues/3458
|
5
|
-
# before_destroy :ensure_not_default
|
6
|
-
|
7
3
|
has_many :addresses, dependent: :restrict_with_error
|
8
4
|
has_many :states,
|
9
5
|
-> { order name: :asc },
|
@@ -18,17 +14,6 @@ module Spree
|
|
18
14
|
|
19
15
|
validates :name, :iso_name, :iso, :iso3, presence: true, uniqueness: { case_sensitive: false, scope: spree_base_uniqueness_scope }
|
20
16
|
|
21
|
-
def self.default(store = nil)
|
22
|
-
Spree::Deprecation.warn(<<-DEPRECATION, caller)
|
23
|
-
`Country#default` is deprecated and will be removed in Spree 5.0.
|
24
|
-
Please use `current_store.default_country` instead
|
25
|
-
DEPRECATION
|
26
|
-
store ||= Spree::Store.default
|
27
|
-
country_id = store.default_country_id
|
28
|
-
default = find_by(id: country_id) if country_id.present?
|
29
|
-
default || find_by(iso: 'US') || first
|
30
|
-
end
|
31
|
-
|
32
17
|
def self.by_iso(iso)
|
33
18
|
where(['LOWER(iso) = ?', iso.downcase]).or(where(['LOWER(iso3) = ?', iso.downcase])).take
|
34
19
|
end
|
@@ -45,16 +30,5 @@ module Spree
|
|
45
30
|
def to_s
|
46
31
|
name
|
47
32
|
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
def ensure_not_default
|
52
|
-
Spree::Deprecation.warn('Country#ensure_not_default is deprecated and will be removed in Spree v5')
|
53
|
-
|
54
|
-
if id.eql?(Spree::Config[:default_country_id])
|
55
|
-
errors.add(:base, Spree.t(:default_country_cannot_be_deleted))
|
56
|
-
throw(:abort)
|
57
|
-
end
|
58
|
-
end
|
59
33
|
end
|
60
34
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Spree
|
2
2
|
class CreditCard < Spree::Base
|
3
3
|
include ActiveMerchant::Billing::CreditCardMethods
|
4
|
-
include Metadata
|
5
|
-
if defined?(Spree::Webhooks)
|
4
|
+
include Spree::Metadata
|
5
|
+
if defined?(Spree::Webhooks::HasWebhooks)
|
6
6
|
include Spree::Webhooks::HasWebhooks
|
7
7
|
end
|
8
8
|
if defined?(Spree::Security::CreditCards)
|
@@ -99,13 +99,15 @@ module Spree
|
|
99
99
|
def cc_type=(type)
|
100
100
|
self[:cc_type] = case type
|
101
101
|
when 'mastercard', 'maestro' then 'master'
|
102
|
-
|
102
|
+
when 'amex' then 'american_express'
|
103
103
|
when 'dinersclub' then 'diners_club'
|
104
104
|
when '' then try_type_from_number
|
105
105
|
else type
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
+
alias_method :brand=, :cc_type=
|
110
|
+
|
109
111
|
def verification_value=(value)
|
110
112
|
@verification_value = value.to_s.gsub(/\s/, '')
|
111
113
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Spree
|
2
2
|
class CustomerReturn < Spree::Base
|
3
3
|
include Spree::Core::NumberGenerator.new(prefix: 'CR', length: 9)
|
4
|
-
include NumberIdentifier
|
5
|
-
include Metadata
|
6
|
-
if defined?(Spree::Webhooks)
|
4
|
+
include Spree::NumberIdentifier
|
5
|
+
include Spree::Metadata
|
6
|
+
if defined?(Spree::Webhooks::HasWebhooks)
|
7
7
|
include Spree::Webhooks::HasWebhooks
|
8
8
|
end
|
9
9
|
|
data/app/models/spree/digital.rb
CHANGED
data/app/models/spree/image.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Spree
|
2
2
|
class Image < Asset
|
3
|
-
include Configuration::ActiveStorage
|
3
|
+
include Spree::Image::Configuration::ActiveStorage
|
4
4
|
include Rails.application.routes.url_helpers
|
5
|
-
include
|
5
|
+
include Spree::ImageMethods
|
6
6
|
|
7
7
|
# In Rails 5.x class constants are being undefined/redefined during the code reloading process
|
8
8
|
# in a rails development environment, after which the actual ruby objects stored in those class constants
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# Default implementation of User. This class is intended to be modified by extensions (ex. spree_auth_devise)
|
2
2
|
module Spree
|
3
3
|
class LegacyUser < Spree::Base
|
4
|
-
include UserAddress
|
5
|
-
include UserPaymentSource
|
6
|
-
include UserMethods
|
4
|
+
include Spree::UserAddress
|
5
|
+
include Spree::UserPaymentSource
|
6
|
+
include Spree::UserMethods
|
7
7
|
include Spree::Metadata
|
8
8
|
|
9
9
|
self.table_name = 'spree_users'
|
data/app/models/spree/menu.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
module Spree
|
2
2
|
class OptionType < Spree::Base
|
3
|
-
include UniqueName
|
4
|
-
include Metadata
|
5
|
-
include TranslatableResource
|
6
|
-
if defined?(Spree::Webhooks)
|
3
|
+
include Spree::UniqueName
|
4
|
+
include Spree::Metadata
|
5
|
+
include Spree::TranslatableResource
|
6
|
+
if defined?(Spree::Webhooks::HasWebhooks)
|
7
7
|
include Spree::Webhooks::HasWebhooks
|
8
8
|
end
|
9
9
|
|
10
|
-
TRANSLATABLE_FIELDS = %i[
|
11
|
-
translates(*TRANSLATABLE_FIELDS)
|
10
|
+
TRANSLATABLE_FIELDS = %i[presentation].freeze
|
11
|
+
translates(*TRANSLATABLE_FIELDS, column_fallback: true)
|
12
12
|
|
13
13
|
acts_as_list
|
14
14
|
auto_strip_attributes :name, :presentation
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module Spree
|
2
2
|
class OptionValue < Spree::Base
|
3
|
-
include Metadata
|
4
|
-
include TranslatableResource
|
5
|
-
if defined?(Spree::Webhooks)
|
3
|
+
include Spree::Metadata
|
4
|
+
include Spree::TranslatableResource
|
5
|
+
if defined?(Spree::Webhooks::HasWebhooks)
|
6
6
|
include Spree::Webhooks::HasWebhooks
|
7
7
|
end
|
8
8
|
|
9
|
-
TRANSLATABLE_FIELDS = %i[
|
10
|
-
translates(*TRANSLATABLE_FIELDS)
|
9
|
+
TRANSLATABLE_FIELDS = %i[presentation].freeze
|
10
|
+
translates(*TRANSLATABLE_FIELDS, column_fallback: true)
|
11
11
|
|
12
12
|
belongs_to :option_type, class_name: 'Spree::OptionType', touch: true, inverse_of: :option_values
|
13
13
|
|
data/app/models/spree/order.rb
CHANGED
@@ -20,12 +20,12 @@ module Spree
|
|
20
20
|
include Spree::Core::NumberGenerator.new(prefix: 'R')
|
21
21
|
include Spree::Core::TokenGenerator
|
22
22
|
|
23
|
-
include NumberIdentifier
|
24
|
-
include NumberAsParam
|
25
|
-
include SingleStoreResource
|
26
|
-
include MemoizedData
|
23
|
+
include Spree::NumberIdentifier
|
24
|
+
include Spree::NumberAsParam
|
25
|
+
include Spree::SingleStoreResource
|
26
|
+
include Spree::MemoizedData
|
27
27
|
include Spree::Metadata
|
28
|
-
if defined?(Spree::Webhooks)
|
28
|
+
if defined?(Spree::Webhooks::HasWebhooks)
|
29
29
|
include Spree::Webhooks::HasWebhooks
|
30
30
|
end
|
31
31
|
if defined?(Spree::Security::Orders)
|
@@ -102,11 +102,13 @@ module Spree
|
|
102
102
|
|
103
103
|
belongs_to :bill_address, foreign_key: :bill_address_id, class_name: 'Spree::Address',
|
104
104
|
optional: true, dependent: :destroy
|
105
|
-
|
105
|
+
alias_method :billing_address, :bill_address
|
106
|
+
alias_method :billing_address=, :bill_address=
|
106
107
|
|
107
108
|
belongs_to :ship_address, foreign_key: :ship_address_id, class_name: 'Spree::Address',
|
108
109
|
optional: true, dependent: :destroy
|
109
|
-
|
110
|
+
alias_method :shipping_address, :ship_address
|
111
|
+
alias_method :shipping_address=, :ship_address=
|
110
112
|
|
111
113
|
belongs_to :store, class_name: 'Spree::Store'
|
112
114
|
|
data/app/models/spree/payment.rb
CHANGED
@@ -3,10 +3,10 @@ require_dependency 'spree/payment/processing'
|
|
3
3
|
module Spree
|
4
4
|
class Payment < Spree::Base
|
5
5
|
include Spree::Core::NumberGenerator.new(prefix: 'P', letters: true, length: 7)
|
6
|
-
include NumberIdentifier
|
7
|
-
include NumberAsParam
|
8
|
-
include Metadata
|
9
|
-
if defined?(Spree::Webhooks)
|
6
|
+
include Spree::NumberIdentifier
|
7
|
+
include Spree::NumberAsParam
|
8
|
+
include Spree::Metadata
|
9
|
+
if defined?(Spree::Webhooks::HasWebhooks)
|
10
10
|
include Spree::Webhooks::HasWebhooks
|
11
11
|
end
|
12
12
|
if defined?(Spree::Security::Payments)
|
data/app/models/spree/price.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Spree
|
2
2
|
class Price < Spree::Base
|
3
|
-
include VatPriceCalculation
|
4
|
-
if defined?(Spree::Webhooks)
|
3
|
+
include Spree::VatPriceCalculation
|
4
|
+
if defined?(Spree::Webhooks::HasWebhooks)
|
5
5
|
include Spree::Webhooks::HasWebhooks
|
6
6
|
end
|
7
7
|
|
@@ -46,7 +46,9 @@ module Spree
|
|
46
46
|
end
|
47
47
|
|
48
48
|
alias_attribute :price, :amount
|
49
|
+
alias_method :price=, :amount=
|
49
50
|
alias_attribute :compare_at_price, :compare_at_amount
|
51
|
+
alias_method :compare_at_price=, :compare_at_amount=
|
50
52
|
|
51
53
|
def price_including_vat_for(price_options)
|
52
54
|
options = price_options.merge(tax_category: variant.tax_category)
|
data/app/models/spree/product.rb
CHANGED
@@ -21,13 +21,13 @@
|
|
21
21
|
module Spree
|
22
22
|
class Product < Spree::Base
|
23
23
|
extend FriendlyId
|
24
|
-
include ProductScopes
|
25
|
-
include MultiStoreResource
|
26
|
-
include TranslatableResource
|
27
|
-
include TranslatableResourceSlug
|
28
|
-
include MemoizedData
|
29
|
-
include Metadata
|
30
|
-
if defined?(Spree::Webhooks)
|
24
|
+
include Spree::ProductScopes
|
25
|
+
include Spree::MultiStoreResource
|
26
|
+
include Spree::TranslatableResource
|
27
|
+
include Spree::TranslatableResourceSlug
|
28
|
+
include Spree::MemoizedData
|
29
|
+
include Spree::Metadata
|
30
|
+
if defined?(Spree::Webhooks::HasWebhooks)
|
31
31
|
include Spree::Webhooks::HasWebhooks
|
32
32
|
end
|
33
33
|
if defined?(Spree::VendorConcern)
|
@@ -39,7 +39,7 @@ module Spree
|
|
39
39
|
purchasable? in_stock? backorderable?]
|
40
40
|
|
41
41
|
TRANSLATABLE_FIELDS = %i[name description slug meta_description meta_keywords meta_title].freeze
|
42
|
-
translates(*TRANSLATABLE_FIELDS)
|
42
|
+
translates(*TRANSLATABLE_FIELDS, column_fallback: true)
|
43
43
|
|
44
44
|
self::Translation.class_eval do
|
45
45
|
before_save :set_slug
|
@@ -332,16 +332,17 @@ module Spree
|
|
332
332
|
end
|
333
333
|
|
334
334
|
def property(property_name)
|
335
|
-
product_properties.joins(:property).
|
336
|
-
join_translation_table(Property).
|
337
|
-
find_by(Property.translation_table_alias => { name: property_name }).try(:value)
|
335
|
+
product_properties.joins(:property).find_by(Property.table_name => { name: property_name }).try(:value)
|
338
336
|
end
|
339
337
|
|
340
338
|
def set_property(property_name, property_value, property_presentation = property_name)
|
341
339
|
ApplicationRecord.transaction do
|
342
340
|
# Manual first_or_create to work around Mobility bug
|
343
341
|
property = if Property.where(name: property_name).exists?
|
344
|
-
Property.where(name: property_name).first
|
342
|
+
existing_property = Property.where(name: property_name).first
|
343
|
+
existing_property.presentation ||= property_presentation
|
344
|
+
existing_property.save
|
345
|
+
existing_property
|
345
346
|
else
|
346
347
|
Property.create(name: property_name, presentation: property_presentation)
|
347
348
|
end
|
@@ -375,16 +376,24 @@ module Spree
|
|
375
376
|
end
|
376
377
|
|
377
378
|
def brand
|
378
|
-
@brand ||=
|
379
|
-
|
380
|
-
|
379
|
+
@brand ||= if Spree.use_translations?
|
380
|
+
taxons.joins(:taxonomy).
|
381
|
+
join_translation_table(Taxonomy).
|
382
|
+
find_by(Taxonomy.translation_table_alias => { name: Spree.t(:taxonomy_brands_name) })
|
383
|
+
else
|
384
|
+
taxons.joins(:taxonomy).find_by(Taxonomy.table_name => { name: Spree.t(:taxonomy_brands_name) })
|
385
|
+
end
|
381
386
|
end
|
382
387
|
|
383
388
|
def category
|
384
|
-
@category ||=
|
385
|
-
|
386
|
-
|
387
|
-
|
389
|
+
@category ||= if Spree.use_translations?
|
390
|
+
taxons.joins(:taxonomy).
|
391
|
+
join_translation_table(Taxonomy).
|
392
|
+
order(depth: :desc).
|
393
|
+
find_by(Taxonomy.translation_table_alias => { name: Spree.t(:taxonomy_categories_name) })
|
394
|
+
else
|
395
|
+
taxons.joins(:taxonomy).order(depth: :desc).find_by(Taxonomy.table_name => { name: Spree.t(:taxonomy_categories_name) })
|
396
|
+
end
|
388
397
|
end
|
389
398
|
|
390
399
|
def taxons_for_store(store)
|
@@ -460,6 +469,8 @@ module Spree
|
|
460
469
|
# punch slug with date prefix to allow reuse of original
|
461
470
|
return if frozen?
|
462
471
|
|
472
|
+
update_column(:slug, "#{Time.current.to_i}_#{slug}"[0..254])
|
473
|
+
|
463
474
|
translations.with_deleted.each do |t|
|
464
475
|
t.update_column :slug, "#{Time.current.to_i}_#{t.slug}"[0..254]
|
465
476
|
end
|