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
@@ -1,15 +1,17 @@
|
|
1
1
|
module Spree
|
2
2
|
class ProductProperty < Spree::Base
|
3
3
|
include Spree::FilterParam
|
4
|
-
include TranslatableResource
|
4
|
+
include Spree::TranslatableResource
|
5
5
|
|
6
|
-
TRANSLATABLE_FIELDS = %i[value
|
7
|
-
translates(*TRANSLATABLE_FIELDS)
|
6
|
+
TRANSLATABLE_FIELDS = %i[value].freeze
|
7
|
+
translates(*TRANSLATABLE_FIELDS, column_fallback: true)
|
8
8
|
|
9
9
|
self::Translation.class_eval do
|
10
10
|
auto_strip_attributes :value
|
11
11
|
end
|
12
12
|
|
13
|
+
auto_strip_attributes :value
|
14
|
+
|
13
15
|
acts_as_list scope: :product
|
14
16
|
|
15
17
|
with_options inverse_of: :product_properties do
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Spree
|
2
2
|
class Promotion < Spree::Base
|
3
|
-
include MultiStoreResource
|
4
|
-
include Metadata
|
5
|
-
if defined?(Spree::Webhooks)
|
3
|
+
include Spree::MultiStoreResource
|
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::Promotions)
|
@@ -1,19 +1,21 @@
|
|
1
1
|
module Spree
|
2
2
|
class Property < Spree::Base
|
3
3
|
include Spree::FilterParam
|
4
|
-
include Metadata
|
5
|
-
include TranslatableResource
|
6
|
-
if defined?(Spree::Webhooks)
|
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
|
self::Translation.class_eval do
|
14
|
-
auto_strip_attributes :
|
14
|
+
auto_strip_attributes :presentation
|
15
15
|
end
|
16
16
|
|
17
|
+
auto_strip_attributes :name, :presentation
|
18
|
+
|
17
19
|
has_many :property_prototypes, class_name: 'Spree::PropertyPrototype'
|
18
20
|
has_many :prototypes, through: :property_prototypes, class_name: 'Spree::Prototype'
|
19
21
|
|
data/app/models/spree/refund.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Spree
|
2
2
|
class Reimbursement < Spree::Base
|
3
3
|
include Spree::Core::NumberGenerator.new(prefix: 'RI', length: 9)
|
4
|
-
include NumberIdentifier
|
5
|
-
if defined?(Spree::Webhooks)
|
4
|
+
include Spree::NumberIdentifier
|
5
|
+
if defined?(Spree::Webhooks::HasWebhooks)
|
6
6
|
include Spree::Webhooks::HasWebhooks
|
7
7
|
end
|
8
8
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Spree
|
2
2
|
class ReturnAuthorization < Spree::Base
|
3
3
|
include Spree::Core::NumberGenerator.new(prefix: 'RA', length: 9)
|
4
|
-
include NumberIdentifier
|
5
|
-
if defined?(Spree::Webhooks)
|
4
|
+
include Spree::NumberIdentifier
|
5
|
+
if defined?(Spree::Webhooks::HasWebhooks)
|
6
6
|
include Spree::Webhooks::HasWebhooks
|
7
7
|
end
|
8
8
|
|
data/app/models/spree/role.rb
CHANGED
@@ -3,10 +3,10 @@ require 'ostruct'
|
|
3
3
|
module Spree
|
4
4
|
class Shipment < Spree::Base
|
5
5
|
include Spree::Core::NumberGenerator.new(prefix: 'H', length: 11)
|
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::Shipments)
|
@@ -2,8 +2,8 @@ module Spree
|
|
2
2
|
class ShippingMethod < Spree::Base
|
3
3
|
acts_as_paranoid
|
4
4
|
include Spree::CalculatedAdjustments
|
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::VendorConcern)
|
@@ -2,8 +2,8 @@ module Spree
|
|
2
2
|
class StockItem < Spree::Base
|
3
3
|
acts_as_paranoid
|
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
|
|
@@ -14,7 +14,7 @@ module Spree
|
|
14
14
|
has_many :stock_movements, inverse_of: :stock_item
|
15
15
|
|
16
16
|
validates :stock_location, :variant, presence: true
|
17
|
-
validates :variant_id, uniqueness: { scope:
|
17
|
+
validates :variant_id, uniqueness: { scope: :stock_location_id }, unless: :deleted_at
|
18
18
|
|
19
19
|
validates :count_on_hand, numericality: {
|
20
20
|
greater_than_or_equal_to: 0,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Spree
|
2
2
|
class StockLocation < Spree::Base
|
3
|
-
include UniqueName
|
4
|
-
if defined?(Spree::Webhooks)
|
3
|
+
include Spree::UniqueName
|
4
|
+
if defined?(Spree::Webhooks::HasWebhooks)
|
5
5
|
include Spree::Webhooks::HasWebhooks
|
6
6
|
end
|
7
7
|
if defined?(Spree::Security::StockLocations)
|
@@ -71,6 +71,11 @@ module Spree
|
|
71
71
|
stock_item(variant_id) || propagate_variant(variant)
|
72
72
|
end
|
73
73
|
|
74
|
+
# Returns the count on hand number for the variant
|
75
|
+
#
|
76
|
+
# @param variant Variant instance
|
77
|
+
#
|
78
|
+
# @return [Integer]
|
74
79
|
def count_on_hand(variant)
|
75
80
|
stock_item(variant).try(:count_on_hand)
|
76
81
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Spree
|
2
2
|
class StockTransfer < Spree::Base
|
3
3
|
include Spree::Core::NumberGenerator.new(prefix: 'T')
|
4
|
-
include NumberIdentifier
|
5
|
-
include NumberAsParam
|
6
|
-
include Metadata
|
7
|
-
if defined?(Spree::Webhooks)
|
4
|
+
include Spree::NumberIdentifier
|
5
|
+
include Spree::NumberAsParam
|
6
|
+
include Spree::Metadata
|
7
|
+
if defined?(Spree::Webhooks::HasWebhooks)
|
8
8
|
include Spree::Webhooks::HasWebhooks
|
9
9
|
end
|
10
10
|
|
data/app/models/spree/store.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Spree
|
2
2
|
class Store < Spree::Base
|
3
|
-
include TranslatableResource
|
4
|
-
if defined?(Spree::Webhooks)
|
3
|
+
include Spree::TranslatableResource
|
4
|
+
if defined?(Spree::Webhooks::HasWebhooks)
|
5
5
|
include Spree::Webhooks::HasWebhooks
|
6
6
|
end
|
7
7
|
if defined?(Spree::Security::Stores)
|
@@ -11,7 +11,7 @@ module Spree
|
|
11
11
|
TRANSLATABLE_FIELDS = %i[name meta_description meta_keywords seo_title facebook
|
12
12
|
twitter instagram customer_support_email description
|
13
13
|
address contact_phone new_order_notifications_email].freeze
|
14
|
-
translates(*TRANSLATABLE_FIELDS)
|
14
|
+
translates(*TRANSLATABLE_FIELDS, column_fallback: true)
|
15
15
|
|
16
16
|
self::Translation.class_eval do
|
17
17
|
acts_as_paranoid
|
@@ -109,8 +109,6 @@ module Spree
|
|
109
109
|
|
110
110
|
after_commit :clear_cache
|
111
111
|
|
112
|
-
alias_attribute :contact_email, :customer_support_email
|
113
|
-
|
114
112
|
def self.current(url = nil)
|
115
113
|
Spree::Deprecation.warn(<<-DEPRECATION, caller)
|
116
114
|
`Spree::Store.current` is deprecated and will be removed in Spree 5.0
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Spree
|
2
2
|
class StoreCredit < Spree::Base
|
3
|
-
include SingleStoreResource
|
4
|
-
include Metadata
|
5
|
-
if defined?(Spree::Webhooks)
|
3
|
+
include Spree::SingleStoreResource
|
4
|
+
include Spree::Metadata
|
5
|
+
if defined?(Spree::Webhooks::HasWebhooks)
|
6
6
|
include Spree::Webhooks::HasWebhooks
|
7
7
|
end
|
8
8
|
|
@@ -10,8 +10,17 @@ module Spree
|
|
10
10
|
|
11
11
|
validates :attachment,
|
12
12
|
content_type: VALID_CONTENT_TYPES,
|
13
|
-
dimension: { max: 256..256 },
|
14
|
-
aspect_ratio: :square,
|
15
13
|
size: { less_than_or_equal_to: 1.megabyte }
|
14
|
+
|
15
|
+
validates :attachment,
|
16
|
+
if: :is_png?,
|
17
|
+
dimension: { max: 256..256 },
|
18
|
+
aspect_ratio: :square
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def is_png?
|
23
|
+
attachment.content_type.in?('image/png')
|
24
|
+
end
|
16
25
|
end
|
17
26
|
end
|
data/app/models/spree/taxon.rb
CHANGED
@@ -3,10 +3,10 @@ require 'stringex'
|
|
3
3
|
|
4
4
|
module Spree
|
5
5
|
class Taxon < Spree::Base
|
6
|
-
include TranslatableResource
|
7
|
-
include TranslatableResourceSlug
|
8
|
-
include Metadata
|
9
|
-
if defined?(Spree::Webhooks)
|
6
|
+
include Spree::TranslatableResource
|
7
|
+
include Spree::TranslatableResourceSlug
|
8
|
+
include Spree::Metadata
|
9
|
+
if defined?(Spree::Webhooks::HasWebhooks)
|
10
10
|
include Spree::Webhooks::HasWebhooks
|
11
11
|
end
|
12
12
|
|
@@ -48,6 +48,8 @@ module Spree
|
|
48
48
|
after_update :sync_taxonomy_name
|
49
49
|
after_touch :touch_ancestors_and_taxonomy
|
50
50
|
|
51
|
+
has_one :store, through: :taxonomy
|
52
|
+
|
51
53
|
has_one :icon, as: :viewable, dependent: :destroy, class_name: 'Spree::TaxonImage'
|
52
54
|
|
53
55
|
scope :for_store, ->(store) { joins(:taxonomy).where(spree_taxonomies: { store_id: store.id }) }
|
@@ -58,7 +60,7 @@ module Spree
|
|
58
60
|
scope :for_stores, ->(stores) { joins(:taxonomy).where(spree_taxonomies: { store_id: stores.ids }) }
|
59
61
|
|
60
62
|
TRANSLATABLE_FIELDS = %i[name description permalink].freeze
|
61
|
-
translates(*TRANSLATABLE_FIELDS)
|
63
|
+
translates(*TRANSLATABLE_FIELDS, column_fallback: true)
|
62
64
|
|
63
65
|
self::Translation.class_eval do
|
64
66
|
alias_attribute :slug, :permalink
|
@@ -117,7 +119,21 @@ module Spree
|
|
117
119
|
|
118
120
|
# Creates permalink base for friendly_id
|
119
121
|
def set_permalink
|
120
|
-
|
122
|
+
if Spree.use_translations?
|
123
|
+
translations.each(&:set_permalink)
|
124
|
+
else
|
125
|
+
self.permalink = generate_slug
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def generate_slug
|
130
|
+
if parent.present?
|
131
|
+
[parent.permalink, (permalink.blank? ? name.to_url : permalink.split('/').last.to_url)].join('/')
|
132
|
+
elsif permalink.blank?
|
133
|
+
name.to_url
|
134
|
+
else
|
135
|
+
permalink.to_url
|
136
|
+
end
|
121
137
|
end
|
122
138
|
|
123
139
|
def active_products
|
@@ -150,7 +166,7 @@ module Spree
|
|
150
166
|
private
|
151
167
|
|
152
168
|
def sync_taxonomy_name
|
153
|
-
if
|
169
|
+
if saved_changes.key?(:name) && root?
|
154
170
|
return if taxonomy.name.to_s == name.to_s
|
155
171
|
|
156
172
|
taxonomy.update(name: name)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Spree
|
2
2
|
class TaxonImage < Asset
|
3
|
-
include Configuration::ActiveStorage
|
3
|
+
include Spree::TaxonImage::Configuration::ActiveStorage
|
4
4
|
include Rails.application.routes.url_helpers
|
5
|
-
include
|
5
|
+
include Spree::ImageMethods
|
6
6
|
|
7
7
|
def styles
|
8
8
|
self.class.styles.map do |_, size|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module Spree
|
2
2
|
class Taxonomy < Spree::Base
|
3
|
-
include TranslatableResource
|
4
|
-
include Metadata
|
5
|
-
if defined?(Spree::Webhooks)
|
3
|
+
include Spree::TranslatableResource
|
4
|
+
include Spree::Metadata
|
5
|
+
if defined?(Spree::Webhooks::HasWebhooks)
|
6
6
|
include Spree::Webhooks::HasWebhooks
|
7
7
|
end
|
8
8
|
|
9
9
|
TRANSLATABLE_FIELDS = %i[name].freeze
|
10
|
-
translates(*TRANSLATABLE_FIELDS)
|
10
|
+
translates(*TRANSLATABLE_FIELDS, column_fallback: true)
|
11
11
|
|
12
12
|
acts_as_list
|
13
13
|
|
@@ -32,7 +32,7 @@ module Spree
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def set_root_taxon_name
|
35
|
-
return unless
|
35
|
+
return unless saved_changes.key?(:name)
|
36
36
|
return if name.to_s == root.name.to_s
|
37
37
|
|
38
38
|
root.update(name: name)
|
data/app/models/spree/variant.rb
CHANGED
@@ -3,9 +3,9 @@ module Spree
|
|
3
3
|
acts_as_paranoid
|
4
4
|
acts_as_list scope: :product
|
5
5
|
|
6
|
-
include MemoizedData
|
7
|
-
include Metadata
|
8
|
-
if defined?(Spree::Webhooks)
|
6
|
+
include Spree::MemoizedData
|
7
|
+
include Spree::Metadata
|
8
|
+
if defined?(Spree::Webhooks::HasWebhooks)
|
9
9
|
include Spree::Webhooks::HasWebhooks
|
10
10
|
end
|
11
11
|
|
@@ -122,9 +122,14 @@ module Spree
|
|
122
122
|
self.whitelisted_ransackable_scopes = %i(product_name_or_sku_cont search_by_product_name_or_sku)
|
123
123
|
|
124
124
|
def self.product_name_or_sku_cont(query)
|
125
|
-
|
126
|
-
|
127
|
-
|
125
|
+
if Spree.use_translations?
|
126
|
+
joins(:product).
|
127
|
+
join_translation_table(Product).
|
128
|
+
where("LOWER(#{Product.translation_table_alias}.name) LIKE LOWER(:query)
|
129
|
+
OR LOWER(sku) LIKE LOWER(:query)", query: "%#{query}%")
|
130
|
+
else
|
131
|
+
joins(:product).where("LOWER(#{Product.table_name}.name) LIKE LOWER(:query) OR LOWER(sku) LIKE LOWER(:query)", query: "%#{query}%")
|
132
|
+
end
|
128
133
|
end
|
129
134
|
|
130
135
|
def self.search_by_product_name_or_sku(query)
|
data/app/models/spree/zone.rb
CHANGED
@@ -9,6 +9,7 @@ module Spree
|
|
9
9
|
def call(address:, address_params:)
|
10
10
|
address_params[:country_id] ||= address.country_id
|
11
11
|
address_params = fill_country_and_state_ids(address_params)
|
12
|
+
address_params[:user_id] = address.user_id if address.user_id.present?
|
12
13
|
|
13
14
|
if address&.editable?
|
14
15
|
address.update(address_params) ? success(address) : failure(address)
|
@@ -4,22 +4,24 @@ module Spree
|
|
4
4
|
prepend Spree::ServiceModule::Base
|
5
5
|
|
6
6
|
def call
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
Spree::Webhooks.disable_webhooks do
|
8
|
+
# GEO
|
9
|
+
Countries.call
|
10
|
+
States.call
|
11
|
+
Zones.call
|
11
12
|
|
12
|
-
|
13
|
-
|
13
|
+
# user roles
|
14
|
+
Roles.call
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
# additional data
|
17
|
+
DefaultReimbursementTypes.call
|
18
|
+
ShippingCategories.call
|
19
|
+
StoreCreditCategories.call
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
# store & stock location
|
22
|
+
Stores.call
|
23
|
+
StockLocations.call
|
24
|
+
end
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
@@ -7,7 +7,7 @@ module Spree
|
|
7
7
|
default_store = Spree::Store.default
|
8
8
|
|
9
9
|
if default_store.persisted?
|
10
|
-
default_store.update!(
|
10
|
+
default_store.update!(default_country: Spree::Country.first)
|
11
11
|
else
|
12
12
|
Spree::Store.new do |s|
|
13
13
|
s.name = 'Spree Demo Site'
|
@@ -16,7 +16,7 @@ module Spree
|
|
16
16
|
s.mail_from_address = 'no-reply@example.com'
|
17
17
|
s.customer_support_email = 'support@example.com'
|
18
18
|
s.default_currency = 'USD'
|
19
|
-
s.
|
19
|
+
s.default_country = Spree::Country.first
|
20
20
|
s.default_locale = I18n.locale
|
21
21
|
s.seo_title = 'Spree Commerce Demo Shop'
|
22
22
|
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/'
|
data/config/routes.rb
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
# see: https://github.com/rails/rails/issues/34872
|
3
3
|
Rails.application.routes.draw do
|
4
4
|
direct :cdn_image do |model, options|
|
5
|
+
options[:host] = Spree.cdn_host if Spree.cdn_host.present?
|
6
|
+
options[:host] ||= Rails.application.routes.default_url_options[:host]
|
7
|
+
|
8
|
+
options[:only_path] = true if options[:host].blank?
|
9
|
+
|
5
10
|
if model.blob.service_name == 'cloudinary' && defined?(Cloudinary)
|
6
11
|
if model.class.method_defined?(:has_mvariation)
|
7
12
|
Cloudinary::Utils.cloudinary_url(model.blob.key,
|
@@ -17,10 +22,7 @@ Rails.application.routes.draw do
|
|
17
22
|
:rails_service_blob_proxy,
|
18
23
|
model.signed_id,
|
19
24
|
model.filename,
|
20
|
-
options
|
21
|
-
host: Spree.cdn_host || Rails.application.routes.default_url_options[:host],
|
22
|
-
port: Rails.application.routes.default_url_options[:port]
|
23
|
-
)
|
25
|
+
options
|
24
26
|
)
|
25
27
|
else
|
26
28
|
signed_blob_id = model.blob.signed_id
|
@@ -32,10 +34,7 @@ Rails.application.routes.draw do
|
|
32
34
|
signed_blob_id,
|
33
35
|
variation_key,
|
34
36
|
filename,
|
35
|
-
options
|
36
|
-
host: Spree.cdn_host || Rails.application.routes.default_url_options[:host],
|
37
|
-
port: Rails.application.routes.default_url_options[:port]
|
38
|
-
)
|
37
|
+
options
|
39
38
|
)
|
40
39
|
end
|
41
40
|
end
|
@@ -1,32 +1,5 @@
|
|
1
1
|
class CreateStockItemStockLocationIdVariantIdCoalesceDeletedAtUniqueIndex < ActiveRecord::Migration[5.2]
|
2
2
|
def change
|
3
|
-
|
4
|
-
reversible do |dir|
|
5
|
-
dir.up do
|
6
|
-
execute <<-SQL
|
7
|
-
CREATE UNIQUE INDEX stock_item_by_loc_var_id_deleted_at
|
8
|
-
ON spree_stock_items(
|
9
|
-
stock_location_id,
|
10
|
-
variant_id,
|
11
|
-
(COALESCE(deleted_at, CAST('1970-01-01' AS #{deleted_at_data_type})))
|
12
|
-
);
|
13
|
-
SQL
|
14
|
-
end
|
15
|
-
|
16
|
-
dir.down do
|
17
|
-
remove_index :spree_stock_items, name: :stock_item_by_loc_var_id_deleted_at
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def deleted_at_data_type
|
25
|
-
case ActiveRecord::Base.connection.adapter_name
|
26
|
-
when 'Mysql2'
|
27
|
-
'DATETIME'
|
28
|
-
when 'PostgreSQL'
|
29
|
-
'TIMESTAMP'
|
30
|
-
end
|
3
|
+
# this migration was broken and is fixed in the following migration
|
31
4
|
end
|
32
5
|
end
|