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.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/app/finders/spree/taxons/find.rb +7 -3
  4. data/app/models/concerns/spree/named_type.rb +1 -1
  5. data/app/models/concerns/spree/product_scopes.rb +19 -19
  6. data/app/models/concerns/spree/user_address.rb +4 -2
  7. data/app/models/spree/address.rb +2 -21
  8. data/app/models/spree/asset.rb +2 -2
  9. data/app/models/spree/calculator/default_tax.rb +1 -1
  10. data/app/models/spree/cms_page.rb +3 -3
  11. data/app/models/spree/cms_section.rb +1 -1
  12. data/app/models/spree/country.rb +0 -26
  13. data/app/models/spree/credit_card.rb +5 -3
  14. data/app/models/spree/customer_return.rb +3 -3
  15. data/app/models/spree/digital.rb +1 -1
  16. data/app/models/spree/digital_link.rb +1 -1
  17. data/app/models/spree/image.rb +2 -2
  18. data/app/models/spree/inventory_unit.rb +1 -1
  19. data/app/models/spree/legacy_user.rb +3 -3
  20. data/app/models/spree/line_item.rb +2 -2
  21. data/app/models/spree/menu.rb +2 -2
  22. data/app/models/spree/menu_item.rb +1 -1
  23. data/app/models/spree/option_type.rb +6 -6
  24. data/app/models/spree/option_value.rb +5 -5
  25. data/app/models/spree/order.rb +9 -7
  26. data/app/models/spree/payment.rb +4 -4
  27. data/app/models/spree/payment_capture_event.rb +1 -1
  28. data/app/models/spree/payment_method.rb +1 -1
  29. data/app/models/spree/payment_source.rb +1 -1
  30. data/app/models/spree/price.rb +4 -2
  31. data/app/models/spree/product.rb +30 -19
  32. data/app/models/spree/product_property.rb +5 -3
  33. data/app/models/spree/promotion.rb +3 -3
  34. data/app/models/spree/property.rb +8 -6
  35. data/app/models/spree/prototype.rb +2 -2
  36. data/app/models/spree/refund.rb +2 -2
  37. data/app/models/spree/reimbursement.rb +2 -2
  38. data/app/models/spree/return_authorization.rb +2 -2
  39. data/app/models/spree/return_item.rb +1 -1
  40. data/app/models/spree/role.rb +1 -1
  41. data/app/models/spree/shipment.rb +4 -4
  42. data/app/models/spree/shipping_category.rb +2 -2
  43. data/app/models/spree/shipping_method.rb +2 -2
  44. data/app/models/spree/stock/estimator.rb +1 -1
  45. data/app/models/spree/stock_item.rb +3 -3
  46. data/app/models/spree/stock_location.rb +7 -2
  47. data/app/models/spree/stock_movement.rb +1 -1
  48. data/app/models/spree/stock_transfer.rb +4 -4
  49. data/app/models/spree/store.rb +3 -5
  50. data/app/models/spree/store_credit.rb +3 -3
  51. data/app/models/spree/store_favicon_image.rb +11 -2
  52. data/app/models/spree/tax_category.rb +1 -1
  53. data/app/models/spree/tax_rate.rb +1 -1
  54. data/app/models/spree/taxon.rb +23 -7
  55. data/app/models/spree/taxon_image.rb +2 -2
  56. data/app/models/spree/taxonomy.rb +5 -5
  57. data/app/models/spree/variant.rb +11 -6
  58. data/app/models/spree/wished_item.rb +1 -1
  59. data/app/models/spree/wishlist.rb +2 -2
  60. data/app/models/spree/zone.rb +2 -2
  61. data/app/services/spree/addresses/update.rb +1 -0
  62. data/app/services/spree/seeds/all.rb +15 -13
  63. data/app/services/spree/seeds/stores.rb +2 -2
  64. data/app/sorters/spree/products/sort.rb +1 -1
  65. data/config/initializers/mobility.rb +1 -0
  66. data/config/routes.rb +7 -8
  67. data/db/migrate/20210929090344_create_stock_item_stock_location_id_variant_id_coalesce_deleted_at_unique_index.rb +1 -28
  68. data/db/migrate/20230103144439_create_option_type_translations.rb +0 -1
  69. data/db/migrate/20230103151034_create_option_value_translations.rb +0 -1
  70. data/db/migrate/20230109084253_create_product_property_translations.rb +0 -1
  71. data/db/migrate/20230109105943_create_property_translations.rb +0 -2
  72. data/db/migrate/20230110142344_backfill_friendly_id_slug_locale.rb +2 -8
  73. data/db/migrate/20240303174340_fix_spree_stock_item_unique_index.rb +35 -0
  74. data/db/migrate/20240514105216_add_weight_and_dimension_units_to_spree_variants.rb +6 -0
  75. data/lib/generators/spree/custom_authentication/custom_authentication_generator.rb +23 -0
  76. data/lib/generators/spree/{custom_user → custom_authentication}/templates/authentication_helpers.rb.tt +1 -14
  77. data/lib/generators/spree/custom_user/custom_user_generator.rb +3 -8
  78. data/lib/generators/spree/custom_user/templates/current_user_helpers.rb.tt +15 -0
  79. data/lib/generators/spree/custom_user/templates/migration.rb.tt +2 -2
  80. data/lib/generators/spree/dummy/dummy_generator.rb +1 -6
  81. data/lib/generators/spree/dummy/templates/rails/database.yml +19 -21
  82. data/lib/generators/spree/dummy/templates/rails/test.rb +1 -1
  83. data/lib/generators/spree/install/templates/config/initializers/spree.rb +25 -0
  84. data/lib/spree/core/configuration.rb +11 -25
  85. data/lib/spree/core/controller_helpers/locale.rb +5 -1
  86. data/lib/spree/core/engine.rb +4 -1
  87. data/lib/spree/core/preferences/runtime_configuration.rb +43 -0
  88. data/lib/spree/core/product_duplicator.rb +2 -0
  89. data/lib/spree/core/product_filters.rb +9 -2
  90. data/lib/spree/core/runtime_configuration.rb +9 -0
  91. data/lib/spree/core/version.rb +1 -1
  92. data/lib/spree/core/webhooks.rb +13 -0
  93. data/lib/spree/core.rb +7 -0
  94. data/lib/spree/money.rb +38 -5
  95. data/lib/spree/testing_support/authorization_helpers.rb +3 -1
  96. data/lib/spree/testing_support/common_rake.rb +7 -18
  97. data/spree_core.gemspec +7 -7
  98. metadata +47 -50
  99. data/db/migrate/20220715120222_change_product_name_null_to_true.rb +0 -5
  100. data/db/migrate/20220718100948_change_taxon_name_null_to_true.rb +0 -5
  101. data/db/migrate/20220804073928_transfer_data_to_translatable_tables.rb +0 -66
  102. data/db/migrate/20230109094907_transfer_options_data_to_translatable_tables.rb +0 -58
  103. data/db/migrate/20230109110840_transfer_property_data_to_translatable_tables.rb +0 -59
  104. data/db/migrate/20230111122511_transfer_product_and_taxon_data_to_translatable_tables.rb +0 -82
  105. data/db/migrate/20230117120430_allow_null_taxonomy_name.rb +0 -5
  106. data/db/migrate/20230117121303_transfer_taxonomy_data_to_translatable_tables.rb +0 -11
  107. data/db/migrate/20230210142849_transfer_store_data_to_translatable_tables.rb +0 -11
  108. 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 filter_param].freeze
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[name presentation filter_param].freeze
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 :name, :presentation
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
 
@@ -1,7 +1,7 @@
1
1
  module Spree
2
2
  class Prototype < Spree::Base
3
- include Metadata
4
- if defined?(Spree::Webhooks)
3
+ include Spree::Metadata
4
+ if defined?(Spree::Webhooks::HasWebhooks)
5
5
  include Spree::Webhooks::HasWebhooks
6
6
  end
7
7
 
@@ -1,7 +1,7 @@
1
1
  module Spree
2
2
  class Refund < Spree::Base
3
- include Metadata
4
- if defined?(Spree::Webhooks)
3
+ include Spree::Metadata
4
+ if defined?(Spree::Webhooks::HasWebhooks)
5
5
  include Spree::Webhooks::HasWebhooks
6
6
  end
7
7
  if defined?(Spree::Security::Refunds)
@@ -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
 
@@ -2,7 +2,7 @@ module Spree
2
2
  class ReturnItem < Spree::Base
3
3
  COMPLETED_RECEPTION_STATUSES = %w(received given_to_customer)
4
4
 
5
- if defined?(Spree::Webhooks)
5
+ if defined?(Spree::Webhooks::HasWebhooks)
6
6
  include Spree::Webhooks::HasWebhooks
7
7
  end
8
8
 
@@ -1,6 +1,6 @@
1
1
  module Spree
2
2
  class Role < Spree::Base
3
- include UniqueName
3
+ include Spree::UniqueName
4
4
 
5
5
  has_many :role_users, class_name: 'Spree::RoleUser', dependent: :destroy
6
6
  has_many :users, through: :role_users, class_name: "::#{Spree.user_class}"
@@ -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)
@@ -1,7 +1,7 @@
1
1
  module Spree
2
2
  class ShippingCategory < 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
 
@@ -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)
@@ -1,7 +1,7 @@
1
1
  module Spree
2
2
  module Stock
3
3
  class Estimator
4
- include VatPriceCalculation
4
+ include Spree::VatPriceCalculation
5
5
 
6
6
  attr_reader :order, :currency
7
7
 
@@ -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: %i[stock_location_id deleted_at] }
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
@@ -5,7 +5,7 @@ module Spree
5
5
  min: -2**31
6
6
  }.freeze
7
7
 
8
- if defined?(Spree::Webhooks)
8
+ if defined?(Spree::Webhooks::HasWebhooks)
9
9
  include Spree::Webhooks::HasWebhooks
10
10
  end
11
11
 
@@ -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
 
@@ -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
@@ -1,6 +1,6 @@
1
1
  module Spree
2
2
  class TaxCategory < Spree::Base
3
- if defined?(Spree::Webhooks)
3
+ if defined?(Spree::Webhooks::HasWebhooks)
4
4
  include Spree::Webhooks::HasWebhooks
5
5
  end
6
6
 
@@ -5,7 +5,7 @@ module Spree
5
5
  include Spree::CalculatedAdjustments
6
6
  include Spree::AdjustmentSource
7
7
  include Spree::Metadata
8
- if defined?(Spree::Webhooks)
8
+ if defined?(Spree::Webhooks::HasWebhooks)
9
9
  include Spree::Webhooks::HasWebhooks
10
10
  end
11
11
 
@@ -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
- translations.each(&:set_permalink)
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 saved_change_to_name? && root?
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 ::Spree::ImageMethods
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 saved_change_to_name?
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)
@@ -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
- joins(:product).join_translation_table(Product).
126
- where("LOWER(#{Product.translation_table_alias}.name) LIKE LOWER(:query)
127
- OR LOWER(sku) LIKE LOWER(:query)", query: "%#{query}%")
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)
@@ -1,6 +1,6 @@
1
1
  module Spree
2
2
  class WishedItem < Spree::Base
3
- if defined?(Spree::Webhooks)
3
+ if defined?(Spree::Webhooks::HasWebhooks)
4
4
  include Spree::Webhooks::HasWebhooks
5
5
  end
6
6
 
@@ -1,7 +1,7 @@
1
1
  module Spree
2
2
  class Wishlist < Spree::Base
3
- include SingleStoreResource
4
- if defined?(Spree::Webhooks)
3
+ include Spree::SingleStoreResource
4
+ if defined?(Spree::Webhooks::HasWebhooks)
5
5
  include Spree::Webhooks::HasWebhooks
6
6
  end
7
7
 
@@ -1,7 +1,7 @@
1
1
  module Spree
2
2
  class Zone < 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
 
@@ -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
- # GEO
8
- Countries.call
9
- States.call
10
- Zones.call
7
+ Spree::Webhooks.disable_webhooks do
8
+ # GEO
9
+ Countries.call
10
+ States.call
11
+ Zones.call
11
12
 
12
- # user roles
13
- Roles.call
13
+ # user roles
14
+ Roles.call
14
15
 
15
- # additional data
16
- DefaultReimbursementTypes.call
17
- ShippingCategories.call
18
- StoreCreditCategories.call
16
+ # additional data
17
+ DefaultReimbursementTypes.call
18
+ ShippingCategories.call
19
+ StoreCreditCategories.call
19
20
 
20
- # store & stock location
21
- Stores.call
22
- StockLocations.call
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!(default_country_id: Spree::Config[:default_country_id])
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.default_country_id = Spree::Config[:default_country_id]
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/'
@@ -11,7 +11,7 @@ module Spree
11
11
  products = by_price(products)
12
12
  products = by_sku(products)
13
13
 
14
- products = select_translatable_fields(products)
14
+ products = select_translatable_fields(products) if Spree.use_translations?
15
15
 
16
16
  products.distinct
17
17
  end
@@ -12,5 +12,6 @@ Mobility.configure do |config|
12
12
  locale_accessors
13
13
  presence
14
14
  dirty
15
+ column_fallback
15
16
  end
16
17
  end
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.merge(
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.merge(
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
- remove_index :spree_stock_items, name: :stock_item_by_loc_var_id_deleted_at
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
@@ -9,7 +9,6 @@ class CreateOptionTypeTranslations < ActiveRecord::Migration[6.1]
9
9
  create_table :spree_option_type_translations do |t|
10
10
 
11
11
  # Translated attribute(s)
12
- t.string :name
13
12
  t.string :presentation
14
13
 
15
14
  t.string :locale, null: false