spree_core 6.0.3 → 6.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. checksums.yaml +4 -4
  2. data/app/jobs/spree/imports/create_rows_job.rb +4 -2
  3. data/app/jobs/spree/imports/process_rows_job.rb +4 -2
  4. data/app/jobs/spree/payments/handle_webhook_job.rb +12 -1
  5. data/app/jobs/spree/products/auto_match_taxons_job.rb +5 -2
  6. data/app/jobs/spree/search_provider/index_job.rb +8 -0
  7. data/app/jobs/spree/search_provider/remove_job.rb +3 -0
  8. data/app/jobs/spree/stock_locations/stock_items/create_job.rb +5 -2
  9. data/app/mailers/spree/base_mailer.rb +1 -1
  10. data/app/models/concerns/spree/acted_by.rb +2 -2
  11. data/app/models/concerns/spree/customer_methods.rb +6 -4
  12. data/app/models/concerns/spree/deprecated_customer_alias.rb +11 -3
  13. data/app/models/concerns/spree/derived_number.rb +1 -1
  14. data/app/models/concerns/spree/has_custom_fields.rb +16 -11
  15. data/app/models/concerns/spree/integrations_concern.rb +5 -3
  16. data/app/models/concerns/spree/label_translatable.rb +4 -4
  17. data/app/models/concerns/spree/metadata.rb +3 -3
  18. data/app/models/concerns/spree/personal_data_matching.rb +5 -1
  19. data/app/models/concerns/spree/presentation_translatable.rb +1 -1
  20. data/app/models/concerns/spree/product_scopes.rb +2 -2
  21. data/app/models/concerns/spree/publishable.rb +26 -3
  22. data/app/models/concerns/spree/purchase/addresses.rb +8 -5
  23. data/app/models/concerns/spree/purchase/deprecated_aliases.rb +2 -2
  24. data/app/models/concerns/spree/stores/markets.rb +4 -2
  25. data/app/models/concerns/spree/user_address.rb +5 -2
  26. data/app/models/concerns/spree/user_methods.rb +2 -2
  27. data/app/models/spree/address.rb +29 -14
  28. data/app/models/spree/asset.rb +3 -3
  29. data/app/models/spree/authentication/strategies/base_strategy.rb +10 -1
  30. data/app/models/spree/base.rb +1 -1
  31. data/app/models/spree/calculator/shipping/flat_rate.rb +6 -4
  32. data/app/models/spree/cart.rb +9 -4
  33. data/app/models/spree/category.rb +8 -6
  34. data/app/models/spree/classification.rb +2 -2
  35. data/app/models/spree/current.rb +19 -0
  36. data/app/models/spree/custom_field.rb +6 -6
  37. data/app/models/spree/custom_field_definition.rb +10 -7
  38. data/app/models/spree/delivery_method.rb +21 -15
  39. data/app/models/spree/delivery_rate.rb +1 -1
  40. data/app/models/spree/digital.rb +1 -1
  41. data/app/models/spree/digital_asset.rb +2 -2
  42. data/app/models/spree/digital_link.rb +4 -4
  43. data/app/models/spree/export.rb +29 -2
  44. data/app/models/spree/fulfillment/custom_events.rb +18 -10
  45. data/app/models/spree/fulfillment.rb +30 -23
  46. data/app/models/spree/fulfillment_item.rb +3 -3
  47. data/app/models/spree/fulfilment_changer.rb +1 -1
  48. data/app/models/spree/gift_card.rb +12 -12
  49. data/app/models/spree/import.rb +23 -15
  50. data/app/models/spree/import_row.rb +6 -6
  51. data/app/models/spree/inventory_unit.rb +1 -1
  52. data/app/models/spree/invitation.rb +14 -6
  53. data/app/models/spree/line_item.rb +10 -8
  54. data/app/models/spree/media.rb +27 -3
  55. data/app/models/spree/metafield.rb +1 -1
  56. data/app/models/spree/metafield_definition.rb +1 -1
  57. data/app/models/spree/metafields.rb +2 -2
  58. data/app/models/spree/option_type.rb +26 -0
  59. data/app/models/spree/option_value.rb +3 -3
  60. data/app/models/spree/order.rb +92 -46
  61. data/app/models/spree/order_inventory.rb +2 -2
  62. data/app/models/spree/order_merger.rb +2 -2
  63. data/app/models/spree/order_updater.rb +34 -20
  64. data/app/models/spree/payment.rb +8 -8
  65. data/app/models/spree/payment_method.rb +11 -9
  66. data/app/models/spree/price.rb +22 -8
  67. data/app/models/spree/price_list.rb +12 -6
  68. data/app/models/spree/price_rules/zone_rule.rb +1 -1
  69. data/app/models/spree/product.rb +32 -33
  70. data/app/models/spree/product_category.rb +10 -4
  71. data/app/models/spree/product_collection.rb +8 -1
  72. data/app/models/spree/promotion/rules/category.rb +27 -10
  73. data/app/models/spree/promotion/rules/country.rb +1 -1
  74. data/app/models/spree/promotion/rules/taxon.rb +4 -2
  75. data/app/models/spree/promotion/rules/user.rb +1 -1
  76. data/app/models/spree/promotion_action.rb +1 -1
  77. data/app/models/spree/promotion_rule_category.rb +5 -5
  78. data/app/models/spree/promotion_rule_taxon.rb +2 -2
  79. data/app/models/spree/prototype.rb +4 -1
  80. data/app/models/spree/return_authorization_reason.rb +3 -3
  81. data/app/models/spree/return_reason.rb +1 -1
  82. data/app/models/spree/search_provider/base.rb +2 -2
  83. data/app/models/spree/search_provider.rb +7 -5
  84. data/app/models/spree/seller.rb +93 -10
  85. data/app/models/spree/seller_requirements/complete_profile.rb +26 -7
  86. data/app/models/spree/shipment.rb +4 -1
  87. data/app/models/spree/shipping_method.rb +4 -1
  88. data/app/models/spree/shipping_rate.rb +1 -1
  89. data/app/models/spree/stock/coordinator.rb +2 -2
  90. data/app/models/spree/stock/estimator.rb +7 -5
  91. data/app/models/spree/stock/package.rb +10 -8
  92. data/app/models/spree/stock_item.rb +1 -1
  93. data/app/models/spree/stock_level/custom_events.rb +1 -1
  94. data/app/models/spree/stock_level.rb +31 -2
  95. data/app/models/spree/stock_location.rb +12 -8
  96. data/app/models/spree/stock_movement.rb +7 -6
  97. data/app/models/spree/stock_reservation.rb +5 -5
  98. data/app/models/spree/store.rb +42 -16
  99. data/app/models/spree/store_credit.rb +2 -2
  100. data/app/models/spree/store_credit_category.rb +5 -5
  101. data/app/models/spree/store_credit_type.rb +2 -2
  102. data/app/models/spree/subscriber.rb +7 -7
  103. data/app/models/spree/tax_rate.rb +5 -5
  104. data/app/models/spree/taxon.rb +3 -3
  105. data/app/models/spree/taxon_rule.rb +2 -2
  106. data/app/models/spree/taxonomy.rb +1 -1
  107. data/app/models/spree/variant.rb +12 -10
  108. data/app/models/spree/variant_media.rb +1 -1
  109. data/app/models/spree/wished_item.rb +1 -1
  110. data/app/models/spree/wishlist.rb +2 -2
  111. data/app/models/spree/wishlist_item/custom_events.rb +2 -2
  112. data/app/models/spree/zone.rb +1 -1
  113. data/app/models/spree/zone_member.rb +1 -1
  114. data/app/services/spree/carts/associate.rb +6 -2
  115. data/app/services/spree/carts/create.rb +1 -1
  116. data/app/services/spree/carts/destroy.rb +23 -7
  117. data/app/services/spree/carts/remove_item.rb +1 -1
  118. data/app/services/spree/carts/remove_line_item.rb +2 -2
  119. data/app/services/spree/carts/remove_out_of_stock_items.rb +3 -1
  120. data/app/services/spree/carts/set_quantity.rb +2 -2
  121. data/app/services/spree/carts/update.rb +17 -0
  122. data/app/services/spree/checkout/add_store_credit.rb +3 -3
  123. data/app/services/spree/checkout/remove_store_credit.rb +2 -2
  124. data/app/services/spree/collections/regenerate_products.rb +37 -15
  125. data/app/services/spree/companies/add_member.rb +9 -4
  126. data/app/services/spree/diagnostics/error_log.rb +139 -0
  127. data/app/services/spree/diagnostics/section.rb +72 -0
  128. data/app/services/spree/diagnostics/sections.rb +121 -0
  129. data/app/services/spree/diagnostics/stack.rb +73 -0
  130. data/app/services/spree/diagnostics.rb +132 -0
  131. data/app/services/spree/imports/row_processors/product_variant.rb +19 -0
  132. data/app/services/spree/newsletter/subscribe.rb +7 -3
  133. data/app/services/spree/orders/approve.rb +3 -3
  134. data/app/services/spree/orders/create_user_account.rb +2 -2
  135. data/app/services/spree/orders/remove_line_item.rb +16 -5
  136. data/app/services/spree/product_memberships.rb +21 -1
  137. data/app/services/spree/product_types/apply_to_products.rb +12 -2
  138. data/app/services/spree/products/auto_match_collections.rb +20 -4
  139. data/app/services/spree/products/auto_match_taxons.rb +5 -2
  140. data/app/services/spree/shipments/update.rb +2 -2
  141. data/app/services/spree/stock_locations/stock_items/create.rb +5 -2
  142. data/app/services/spree/stock_reservations/extend.rb +3 -1
  143. data/app/services/spree/stock_reservations/reserve.rb +12 -7
  144. data/app/services/spree/store_credits/apply.rb +9 -1
  145. data/app/services/spree/taxons/add_products.rb +4 -2
  146. data/app/services/spree/taxons/regenerate_products.rb +5 -2
  147. data/app/services/spree/taxons/remove_products.rb +4 -2
  148. data/app/services/spree/update_check.rb +7 -31
  149. data/app/tools/spree/agent_tools/describe_resource.rb +3 -0
  150. data/app/tools/spree/agent_tools/get_resource.rb +1 -1
  151. data/app/tools/spree/agent_tools/resource_write.rb +1 -1
  152. data/app/tools/spree/agent_tools/search_resources.rb +42 -10
  153. data/app/workflows/spree/carts/add_item.rb +52 -1
  154. data/app/workflows/spree/carts/complete.rb +14 -2
  155. data/app/workflows/spree/carts/recalculate.rb +1 -1
  156. data/app/workflows/spree/fulfillments/update.rb +1 -1
  157. data/app/workflows/spree/orders/cancel.rb +3 -1
  158. data/app/workflows/spree/payments/capture.rb +2 -2
  159. data/app/workflows/spree/payments/handle_webhook.rb +7 -3
  160. data/app/workflows/spree/seller_transfers/create.rb +1 -1
  161. data/app/workflows/spree/sellers/approve.rb +6 -0
  162. data/app/workflows/spree/sellers/create.rb +5 -2
  163. data/app/workflows/spree/stock_levels/bulk_upsert.rb +19 -7
  164. data/config/locales/be.yml +1 -1
  165. data/config/locales/en.yml +12 -0
  166. data/config/locales/fr.yml +1 -1
  167. data/config/locales/lt.yml +1 -1
  168. data/config/locales/ru.yml +1 -1
  169. data/config/locales/uk.yml +1 -1
  170. data/db/migrate/20240303174340_fix_spree_stock_item_unique_index.rb +14 -10
  171. data/db/migrate/20260710000001_rename_taxons_to_categories.rb +1 -1
  172. data/db/migrate/20260728000004_rename_shipping_to_fulfillment_and_delivery.rb +1 -1
  173. data/db/migrate/20260806000001_add_store_id_to_spree_tax_rates_and_categories.rb +1 -1
  174. data/db/migrate/20260807130001_add_country_state_codes_to_consumers.rb +1 -1
  175. data/db/migrate/20260809000001_rename_metafields_to_custom_fields.rb +1 -1
  176. data/db/migrate/20260809150001_promote_shipping_categories_to_delivery_profiles.rb +1 -1
  177. data/db/migrate/20260811000001_add_delivery_tracking_to_fulfillments.rb +1 -1
  178. data/db/migrate/20260814000001_rename_stock_items_to_stock_levels.rb +13 -7
  179. data/db/migrate/20260824000001_add_store_to_spree_media.rb +1 -1
  180. data/db/migrate/20260828100001_unify_import_and_export_tenancy.rb +1 -1
  181. data/db/migrate/20261016000001_remove_default_from_spree_tax_rates_included_in_price.rb +1 -1
  182. data/lib/spree/agent_tool.rb +3 -3
  183. data/lib/spree/agent_tools/default_catalog.rb +2 -2
  184. data/lib/spree/agent_tools/legacy_tools.rb +1 -1
  185. data/lib/spree/agent_tools/operation_tool.rb +1 -1
  186. data/lib/spree/agent_tools/record_summary.rb +8 -2
  187. data/lib/spree/agent_tools/resource_map.rb +82 -7
  188. data/lib/spree/core/dependencies.rb +10 -10
  189. data/lib/spree/core/engine.rb +14 -0
  190. data/lib/spree/core/number_generator.rb +4 -3
  191. data/lib/spree/core/preferences/preferable.rb +1 -1
  192. data/lib/spree/core/preferences/preferable_class_methods.rb +5 -1
  193. data/lib/spree/core/pricing/resolver.rb +2 -2
  194. data/lib/spree/core/version.rb +1 -1
  195. data/lib/spree/core.rb +48 -10
  196. data/lib/spree/i18n.rb +6 -2
  197. data/lib/spree/localized_number.rb +1 -1
  198. data/lib/spree/removed_apis.rb +274 -0
  199. data/lib/spree/reporting/default_vocabulary.rb +26 -6
  200. data/lib/spree/testing_support/factories/digital_asset_factory.rb +1 -1
  201. data/lib/spree/testing_support/factories/stock_level_factory.rb +1 -1
  202. data/lib/spree/testing_support/factories/taxon_factory.rb +1 -1
  203. data/lib/spree/testing_support/factories/taxonomy_factory.rb +1 -1
  204. data/lib/spree/testing_support/factories/wishlist_item_factory.rb +1 -1
  205. data/lib/spree/testing_support/i18n.rb +7 -2
  206. data/lib/spree/testing_support/order_walkthrough.rb +5 -2
  207. data/lib/spree/upgrades/5_6_to_6_0/manifest.yml +14 -14
  208. data/lib/tasks/carts_migration.rake +1 -1
  209. data/lib/tasks/categories_and_collections.rake +1 -1
  210. data/lib/tasks/deliveries_migration.rake +1 -1
  211. data/lib/tasks/delivery_method_rules_migration.rake +1 -1
  212. data/lib/tasks/delivery_migration.rake +1 -1
  213. data/lib/tasks/delivery_profiles_migration.rake +2 -2
  214. data/lib/tasks/diagnostics.rake +11 -0
  215. data/lib/tasks/fold_store_credit_categories.rake +1 -1
  216. data/lib/tasks/migrate_country_state_codes.rake +1 -1
  217. data/lib/tasks/migrate_returns.rake +4 -4
  218. data/lib/tasks/migrate_rich_text_to_columns.rake +1 -1
  219. data/lib/tasks/store_settings.rake +1 -1
  220. data/lib/tasks/typed_stock_movements_migration.rake +1 -1
  221. metadata +13 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a2157ca6ce976c9676d3c814939c6a69e8fd835b8864d73006b274f1216f2d4e
4
- data.tar.gz: 8a80c4a0d322fafe8ff3f4accb3bf293bfca4f4cf341a98015e8a494c0373185
3
+ metadata.gz: d62d8e35b3c55f0a54ef1afb0e8270bfb1391899f12b3959ca6959324953e84d
4
+ data.tar.gz: bd148a4547773fff7263a12765b45f5c2573612190ca06293204a7c25c73d775
5
5
  SHA512:
6
- metadata.gz: 290b7d040a689ce9be4d01e20713ca97476d8b2b5ab1e8e735fad6bf651103375f037e2f96bb767662b866069d6c01219eae6d5d8da1de2ffed3a1e01756ab25
7
- data.tar.gz: bd9a079e8712771a6a77453e9ae63bdf6a75a39d549c3db86eb326a5f7ab60896e6ff2196274380d5805f583487b43a24f0c198feb780ab40bddf11c1b0e26bb
6
+ metadata.gz: cacd3ad126f55a1cf7ec44ed1d243041bf1617ea3a38a303373995c39a96c9e2b6ab6d7eaf17f11ba4ba0bca7ee63dba8a4b3b3e7185473849afdd6a99afde68
7
+ data.tar.gz: 27d668eb15bc37af05a04143de22cabc308dec4c14d2e63a15b8697d7c97ee3e18eedd82ce7844aeae6528abda210a629839f5fe21e507cd41be861d287b78e5
@@ -1,9 +1,11 @@
1
1
  module Spree
2
2
  module Imports
3
- # @deprecated Use {Spree::Imports::ProcessJob}; removed in 6.1.
3
+ # @deprecated Use {Spree::Imports::ProcessJob}; removed in 6.3.
4
4
  class CreateRowsJob < Spree::Imports::BaseJob
5
5
  def perform(import_id)
6
- Spree::Deprecation.warn('Spree::Imports::CreateRowsJob is deprecated and will be removed in Spree 6.1. Use Spree::Imports::ProcessJob instead.')
6
+ Spree::Deprecation.warn(
7
+ 'Spree::Imports::CreateRowsJob is deprecated and will be removed in Spree 6.3. Use Spree::Imports::ProcessJob instead.'
8
+ )
7
9
  Spree::Imports::ProcessJob.perform_now(import_id)
8
10
  end
9
11
  end
@@ -1,10 +1,12 @@
1
1
  module Spree
2
2
  module Imports
3
3
  # @deprecated Use {Spree::Imports::ProcessJob} with skip_row_creation:
4
- # true; removed in 6.1.
4
+ # true; removed in 6.3.
5
5
  class ProcessRowsJob < Spree::Imports::BaseJob
6
6
  def perform(import_id)
7
- Spree::Deprecation.warn('Spree::Imports::ProcessRowsJob is deprecated and will be removed in Spree 6.1. Use Spree::Imports::ProcessJob instead.')
7
+ Spree::Deprecation.warn(
8
+ 'Spree::Imports::ProcessRowsJob is deprecated and will be removed in Spree 6.3. Use Spree::Imports::ProcessJob instead.'
9
+ )
8
10
  Spree::Imports::ProcessJob.perform_now(import_id, skip_row_creation: true)
9
11
  end
10
12
  end
@@ -7,16 +7,27 @@ module Spree
7
7
  retry_on ActiveRecord::LockWaitTimeout, wait: 5.seconds, attempts: 3
8
8
  discard_on ActiveRecord::RecordNotFound
9
9
 
10
+ # The gateway got its 200 when this job was enqueued and will not send
11
+ # the webhook again, so a failed settlement (a gateway 5xx, a lock
12
+ # timeout swallowed by the workflow) must be retried here or the
13
+ # buyer is charged without an order. Safe to replay: the workflow
14
+ # skips a payment that is already completed.
15
+ class SettlementFailed < StandardError; end
16
+
17
+ retry_on SettlementFailed, wait: :polynomially_longer, attempts: 5
18
+
10
19
  def perform(payment_method_id:, action:, payment_session_id:)
11
20
  payment_method = Spree::PaymentMethod.find(payment_method_id)
12
21
  Spree::Current.store = payment_method.store
13
22
  payment_session = Spree::PaymentSession.find(payment_session_id)
14
23
 
15
- Spree.payments_handle_webhook_workflow.call(
24
+ result = Spree.payments_handle_webhook_workflow.call(
16
25
  payment_method: payment_method,
17
26
  action: action.to_sym,
18
27
  payment_session: payment_session
19
28
  )
29
+
30
+ raise SettlementFailed, "Payment session #{payment_session.id}: #{result.error}" if result&.failure?
20
31
  end
21
32
  end
22
33
  end
@@ -2,10 +2,13 @@ module Spree
2
2
  module Products
3
3
  # @deprecated Renamed to AutoMatchCollectionsJob in 6.0 (behavior moved to
4
4
  # collections). Subclasses it so jobs enqueued under the old class name still
5
- # deserialize and run; removed in 6.1.
5
+ # deserialize and run; removed in 6.3.
6
6
  class AutoMatchTaxonsJob < AutoMatchCollectionsJob
7
7
  def perform(product_id)
8
- Spree::Deprecation.warn('Spree::Products::AutoMatchTaxonsJob is deprecated and will be removed in Spree 6.1. Use Spree::Products::AutoMatchCollectionsJob instead.')
8
+ Spree::Deprecation.warn(
9
+ 'Spree::Products::AutoMatchTaxonsJob is deprecated and will be removed in Spree 6.3. ' \
10
+ 'Use Spree::Products::AutoMatchCollectionsJob instead.'
11
+ )
9
12
  super
10
13
  end
11
14
  end
@@ -3,6 +3,14 @@ module Spree
3
3
  class IndexJob < Spree::BaseJob
4
4
  queue_as Spree.queues.search
5
5
 
6
+ # A bulk write (CSV import, sample data) enqueues thousands of these at
7
+ # once; run in parallel they flood the search service with requests and
8
+ # it answers 429 Too Many Requests. Run one search job per store at a
9
+ # time; the rest wait as blocked executions, so no update is lost. Shared
10
+ # with RemoveJob. The duration only has to outlive one job; expiry lifts
11
+ # the cap, it doesn't drop jobs. Solid Queue only (no-op elsewhere).
12
+ limits_concurrency to: 1, key: ->(*, store_id) { store_id }, group: 'spree_search', duration: 5.minutes if respond_to?(:limits_concurrency)
13
+
6
14
  # Search providers are external services (Meilisearch, etc.); a transient 5xx or
7
15
  # network blip should not drop the index update.
8
16
  retry_on StandardError, wait: :polynomially_longer, attempts: 5
@@ -3,6 +3,9 @@ module Spree
3
3
  class RemoveJob < Spree::BaseJob
4
4
  queue_as Spree.queues.search
5
5
 
6
+ # Shares IndexJob's per-store limit, see there.
7
+ limits_concurrency to: 1, key: ->(*, store_id) { store_id }, group: 'spree_search', duration: 5.minutes if respond_to?(:limits_concurrency)
8
+
6
9
  # Search providers are external services; broad retry covers network blips and 5xx.
7
10
  retry_on StandardError, wait: :polynomially_longer, attempts: 5
8
11
  # Must come after `retry_on StandardError` so DeserializationError lands in discard
@@ -3,10 +3,13 @@ module Spree
3
3
  module StockItems
4
4
  # @deprecated Renamed to Spree::StockLocations::StockLevels::CreateJob in 6.0.
5
5
  # Subclasses it so jobs enqueued under the old class name before the deploy
6
- # still deserialize and run; removed in 6.1.
6
+ # still deserialize and run; removed in 6.3.
7
7
  class CreateJob < StockLevels::CreateJob
8
8
  def perform(*args)
9
- Spree::Deprecation.warn('Spree::StockLocations::StockItems::CreateJob is deprecated and will be removed in Spree 6.1. Use Spree::StockLocations::StockLevels::CreateJob instead.')
9
+ Spree::Deprecation.warn(
10
+ 'Spree::StockLocations::StockItems::CreateJob is deprecated and will be removed in Spree 6.3. ' \
11
+ 'Use Spree::StockLocations::StockLevels::CreateJob instead.'
12
+ )
10
13
  super
11
14
  end
12
15
  end
@@ -29,7 +29,7 @@ module Spree
29
29
  @_store_locale_active = true
30
30
  begin
31
31
  Spree::Locales::SetFallbackLocaleForStore.new.call(store: store) if store
32
- I18n.with_locale(locale, &block)
32
+ Spree::Current.with_content_locale(store&.default_market&.default_locale) { I18n.with_locale(locale, &block) }
33
33
  ensure
34
34
  @_store_locale_active = previously_active
35
35
  Mobility.store_based_fallbacks = previous_fallbacks
@@ -178,7 +178,7 @@ module Spree
178
178
  # Prepended rather than defined outright, so `super` reaches the
179
179
  # generated reader.
180
180
  #
181
- # Removed in 6.1, once the backfill is a release behind.
181
+ # Removed in 6.3, once the backfill is a release behind.
182
182
  def define_transitional_actor_reader(name)
183
183
  transitional_actor_readers.module_eval do
184
184
  define_method(name) do
@@ -188,7 +188,7 @@ module Spree
188
188
  Spree::Deprecation.warn(
189
189
  "#{self.class.name}##{name} resolved through #{Spree.admin_user_class} because " \
190
190
  "#{name}_type is blank. Run `rake spree:upgrade:backfill_actor_types`; the fallback " \
191
- 'is removed in Spree 6.1.'
191
+ 'is removed in Spree 6.3.'
192
192
  )
193
193
 
194
194
  # Fill the type across the whole lazily-preloaded group, not just
@@ -295,14 +295,14 @@ module Spree
295
295
  # @deprecated Carts are {Spree::Cart} since 6.0, so an incomplete order is
296
296
  # a backoffice draft rather than the customer's cart. Use
297
297
  # +carts.where(store: store)+ for carts, or +orders.drafts+ for drafts.
298
- # Removed in Spree 6.1.
298
+ # Removed in Spree 6.3.
299
299
  # @param [Spree::Store] store
300
300
  # @param [Hash] options
301
301
  # @option options [Array<Symbol>] :includes
302
302
  # @return [Spree::Order]
303
303
  def last_incomplete_spree_order(store, options = {})
304
304
  Spree::Deprecation.warn(
305
- 'Spree::CustomerMethods#last_incomplete_spree_order is deprecated and will be removed in Spree 6.1. ' \
305
+ 'Spree::CustomerMethods#last_incomplete_spree_order is deprecated and will be removed in Spree 6.3. ' \
306
306
  'Carts are Spree::Cart since 6.0 and this returns draft orders; use #carts for the customer\'s carts.'
307
307
  )
308
308
 
@@ -393,9 +393,11 @@ module Spree
393
393
  # every column carrying personal data rather than three on this row —
394
394
  # the address book, the address snapshots on past orders, gateway
395
395
  # profiles, OAuth identities and live sessions all outlived this method.
396
- # Removed in Spree 6.1.
396
+ # Removed in Spree 6.3.
397
397
  def scramble_email_and_names
398
- Spree::Deprecation.warn('Spree::CustomerMethods#scramble_email_and_names is deprecated and will be removed in Spree 6.1. Use Spree::Customers::Anonymize instead.')
398
+ Spree::Deprecation.warn(
399
+ 'Spree::CustomerMethods#scramble_email_and_names is deprecated and will be removed in Spree 6.3. Use Spree::Customers::Anonymize instead.'
400
+ )
399
401
 
400
402
  Spree.customer_anonymize_workflow.call(customer: self, store: Spree::Current.store).success?
401
403
  end
@@ -1,7 +1,7 @@
1
1
  module Spree
2
2
  # Deprecation shim for the 6.0 user_id -> customer_id / belongs_to :user -> :customer
3
3
  # rename. Included by customer-facing models so `.user` / `.user_id` keep working
4
- # for one release. Remove in Spree 6.1.
4
+ # until Spree 6.3.
5
5
  module DeprecatedCustomerAlias
6
6
  extend ActiveSupport::Concern
7
7
 
@@ -10,12 +10,20 @@ module Spree
10
10
  end
11
11
 
12
12
  def user
13
- Spree::Deprecation.warn("#{self.class}#user is deprecated and will be removed in Spree 6.1. Use #customer instead.") if defined?(Spree::Deprecation)
13
+ if defined?(Spree::Deprecation)
14
+ Spree::Deprecation.warn(
15
+ "#{self.class}#user is deprecated and will be removed in Spree 6.3. Use #customer instead."
16
+ )
17
+ end
14
18
  customer
15
19
  end
16
20
 
17
21
  def user=(value)
18
- Spree::Deprecation.warn("#{self.class}#user= is deprecated and will be removed in Spree 6.1. Use #customer= instead.") if defined?(Spree::Deprecation)
22
+ if defined?(Spree::Deprecation)
23
+ Spree::Deprecation.warn(
24
+ "#{self.class}#user= is deprecated and will be removed in Spree 6.3. Use #customer= instead."
25
+ )
26
+ end
19
27
  self.customer = value
20
28
  end
21
29
  end
@@ -11,7 +11,7 @@ module Spree
11
11
  #
12
12
  # Rows created before 6.0 keep their stored number, so gateway references
13
13
  # and packing slips already in the wild still resolve. New rows never write
14
- # the column — it is frozen legacy data awaiting the 6.1 drop.
14
+ # the column — it is frozen legacy data awaiting the 6.3 drop.
15
15
  module DerivedNumber
16
16
  extend ActiveSupport::Concern
17
17
 
@@ -22,28 +22,33 @@ module Spree
22
22
  [namespace, key]
23
23
  end
24
24
 
25
- # Deprecated 6.0 names, removed in 6.1.
25
+ # Deprecated 6.0 names, removed in 6.3.
26
26
  def ensure_metafield_definition_exists!(key_with_namespace, store: Spree::Current.store)
27
- Spree::Deprecation.warn('ensure_metafield_definition_exists! is deprecated and will be removed in Spree 6.1. Use ensure_custom_field_definition_exists! instead.')
27
+ Spree::Deprecation.warn(
28
+ 'ensure_metafield_definition_exists! is deprecated and will be removed in Spree 6.3. Use ensure_custom_field_definition_exists! instead.'
29
+ )
28
30
  ensure_custom_field_definition_exists!(key_with_namespace, store: store)
29
31
  end
30
32
 
31
33
  def with_metafield_key(key_with_namespace)
32
- Spree::Deprecation.warn('.with_metafield_key is deprecated and will be removed in Spree 6.1. Use .with_custom_field_key instead.')
34
+ Spree::Deprecation.warn('.with_metafield_key is deprecated and will be removed in Spree 6.3. Use .with_custom_field_key instead.')
33
35
  with_custom_field_key(key_with_namespace)
34
36
  end
35
37
 
36
38
  def with_metafield_key_value(key_with_namespace, value)
37
- Spree::Deprecation.warn('.with_metafield_key_value is deprecated and will be removed in Spree 6.1. Use .with_custom_field_key_value instead.')
39
+ Spree::Deprecation.warn('.with_metafield_key_value is deprecated and will be removed in Spree 6.3. Use .with_custom_field_key_value instead.')
38
40
  with_custom_field_key_value(key_with_namespace, value)
39
41
  end
40
42
  end
41
43
 
42
44
  included do
43
- has_many :custom_fields, -> { includes(:custom_field_definition) }, as: :resource, class_name: 'Spree::CustomField', dependent: :destroy
45
+ # The explicit inverse lets a custom field built on an unsaved owner find that owner when
46
+ # it is saved. Rails cannot infer it for a scoped association, so without it the row is
47
+ # inserted with a NULL resource_id unless the app happens to enable `has_many_inversing`.
48
+ has_many :custom_fields, -> { includes(:custom_field_definition) }, as: :resource, inverse_of: :resource, class_name: 'Spree::CustomField', dependent: :destroy
44
49
  has_many :storefront_custom_fields, -> { includes(:custom_field_definition).storefront_visible }, as: :resource, class_name: 'Spree::CustomField'
45
50
 
46
- # Deprecated 6.0 association names, removed in 6.1. `private_metafields`
51
+ # Deprecated 6.0 association names, removed in 6.3. `private_metafields`
47
52
  # has no replacement — read `custom_fields` and filter, or query
48
53
  # Spree::CustomField.admin_only directly.
49
54
  has_many :metafields, -> { includes(:custom_field_definition) }, as: :resource, class_name: 'Spree::CustomField', deprecated: true
@@ -167,26 +172,26 @@ module Spree
167
172
  custom_fields.with_key(namespace, key).exists?
168
173
  end
169
174
 
170
- # Deprecated 6.0 names, removed in 6.1.
175
+ # Deprecated 6.0 names, removed in 6.3.
171
176
  def set_metafield(definition_or_key, value)
172
- Spree::Deprecation.warn('#set_metafield is deprecated and will be removed in Spree 6.1. Use #set_custom_field instead.')
177
+ Spree::Deprecation.warn('#set_metafield is deprecated and will be removed in Spree 6.3. Use #set_custom_field instead.')
173
178
  set_custom_field(definition_or_key, value)
174
179
  end
175
180
 
176
181
  def get_metafield(key_with_namespace)
177
- Spree::Deprecation.warn('#get_metafield is deprecated and will be removed in Spree 6.1. Use #get_custom_field instead.')
182
+ Spree::Deprecation.warn('#get_metafield is deprecated and will be removed in Spree 6.3. Use #get_custom_field instead.')
178
183
  get_custom_field(key_with_namespace)
179
184
  end
180
185
 
181
186
  def has_metafield?(key_with_namespace)
182
- Spree::Deprecation.warn('#has_metafield? is deprecated and will be removed in Spree 6.1. Use #has_custom_field? instead.')
187
+ Spree::Deprecation.warn('#has_metafield? is deprecated and will be removed in Spree 6.3. Use #has_custom_field? instead.')
183
188
  has_custom_field?(key_with_namespace)
184
189
  end
185
190
 
186
191
  # Legacy payloads key the definition as `metafield_definition_id`, which
187
192
  # the new writer rejects — translate rather than silently dropping them.
188
193
  def metafields_attributes=(attributes)
189
- Spree::Deprecation.warn('#metafields_attributes= is deprecated and will be removed in Spree 6.1. Use #custom_fields_attributes= instead.')
194
+ Spree::Deprecation.warn('#metafields_attributes= is deprecated and will be removed in Spree 6.3. Use #custom_fields_attributes= instead.')
190
195
 
191
196
  attributes = attributes.values if attributes.is_a?(Hash)
192
197
  translated = attributes.map do |attrs|
@@ -1,5 +1,5 @@
1
1
  module Spree
2
- # @deprecated Use {Spree::Current.integrations}; removed in Spree 6.1.
2
+ # @deprecated Use {Spree::Current.integrations}; removed in Spree 6.3.
3
3
  #
4
4
  # Nothing in Spree calls these — the per-request integration set lives on
5
5
  # {Spree::Current} — but the concern sits on Spree::Base, so every model has
@@ -7,7 +7,8 @@ module Spree
7
7
  module IntegrationsConcern
8
8
  def store_integrations
9
9
  Spree::Deprecation.warn(
10
- 'Spree::IntegrationsConcern#store_integrations is deprecated and will be removed in Spree 6.1. ' 'Use Spree::Current.integrations instead.'
10
+ 'Spree::IntegrationsConcern#store_integrations is deprecated and will be removed in Spree 6.3. ' \
11
+ 'Use Spree::Current.integrations instead.'
11
12
  )
12
13
 
13
14
  Spree::Current.integrations
@@ -15,7 +16,8 @@ module Spree
15
16
 
16
17
  def store_integration(name)
17
18
  Spree::Deprecation.warn(
18
- 'Spree::IntegrationsConcern#store_integration is deprecated and will be removed in Spree 6.1. ' 'Use Spree::Current.integrations.find { |integration| integration.type.to_s.demodulize.underscore == name } instead.'
19
+ 'Spree::IntegrationsConcern#store_integration is deprecated and will be removed in Spree 6.3. ' \
20
+ 'Use Spree::Current.integrations.find { |integration| integration.type.to_s.demodulize.underscore == name } instead.'
19
21
  )
20
22
 
21
23
  Spree::Current.integrations.find { |integration| integration.type.to_s.demodulize.underscore == name }
@@ -16,7 +16,7 @@ module Spree
16
16
  end
17
17
  end
18
18
 
19
- # @deprecated The column is +label+ since 6.0; removed in 6.1.
19
+ # @deprecated The column is +label+ since 6.0; removed in 6.3.
20
20
  #
21
21
  # Unlike the attribute aliases the other 6.0 renames use, this is a plain
22
22
  # method — Mobility owns +label+, so it cannot be an alias_attribute. It
@@ -24,13 +24,13 @@ module Spree
24
24
  # and +find_by(presentation:)+ name a column that no longer exists and
25
25
  # raise. Query by +label+.
26
26
  def presentation(*args, **kwargs)
27
- Spree::Deprecation.warn("#{self.class.name}#presentation is deprecated and will be removed in Spree 6.1. Use #label instead.")
27
+ Spree::Deprecation.warn("#{self.class.name}#presentation is deprecated and will be removed in Spree 6.3. Use #label instead.")
28
28
  label(*args, **kwargs)
29
29
  end
30
30
 
31
- # @deprecated See {#presentation}; removed in 6.1.
31
+ # @deprecated See {#presentation}; removed in 6.3.
32
32
  def presentation=(value)
33
- Spree::Deprecation.warn("#{self.class.name}#presentation= is deprecated and will be removed in Spree 6.1. Use #label= instead.")
33
+ Spree::Deprecation.warn("#{self.class.name}#presentation= is deprecated and will be removed in Spree 6.3. Use #label= instead.")
34
34
  self.label = value
35
35
  end
36
36
  end
@@ -11,7 +11,7 @@ module Spree
11
11
  serialize :metadata, coder: HashSerializer
12
12
  end
13
13
 
14
- # Deprecated alias for the renamed `metadata` column. Removed in Spree 6.1.
14
+ # Deprecated alias for the renamed `metadata` column. Removed in Spree 6.3.
15
15
  #
16
16
  # Only the reader and writer are bridged. The column is gone, so the attribute
17
17
  # methods Active Record generated alongside it — `private_metadata?`,
@@ -19,12 +19,12 @@ module Spree
19
19
  # `private_metadata_before_type_cast` and the rest of the dirty-tracking family
20
20
  # — no longer exist and raise NoMethodError. Call the `metadata` equivalents.
21
21
  def private_metadata
22
- Spree::Deprecation.warn('private_metadata is deprecated and will be removed in Spree 6.1. Use metadata instead.')
22
+ Spree::Deprecation.warn('private_metadata is deprecated and will be removed in Spree 6.3. Use metadata instead.')
23
23
  metadata
24
24
  end
25
25
 
26
26
  def private_metadata=(value)
27
- Spree::Deprecation.warn('private_metadata= is deprecated and will be removed in Spree 6.1. Use metadata= instead.')
27
+ Spree::Deprecation.warn('private_metadata= is deprecated and will be removed in Spree 6.3. Use metadata= instead.')
28
28
  self.metadata = value
29
29
  end
30
30
 
@@ -90,11 +90,15 @@ module Spree
90
90
 
91
91
  # Rows of `model` whose `email` is this address, whatever its casing.
92
92
  #
93
+ # The exact match goes through the model, so a table whose email the app
94
+ # encrypts is still matched: SQL only ever sees its ciphertext.
95
+ #
93
96
  # @param model [Class]
94
97
  # @param email [String]
95
98
  # @return [ActiveRecord::Relation]
96
99
  def with_email(model, email)
97
- model.where(model.arel_table[:email].lower.eq(email.to_s.downcase))
100
+ model.where(email: email.to_s).
101
+ or(model.where(model.arel_table[:email].lower.eq(email.to_s.downcase)))
98
102
  end
99
103
 
100
104
  # Rows at this address that no *other* person already owns.
@@ -1,6 +1,6 @@
1
1
  module Spree
2
2
  # Constant alias for the legacy Spree::PresentationTranslatable, renamed to
3
3
  # Spree::LabelTranslatable in 6.0 along with the column it wrapped.
4
- # Remove in 6.1.
4
+ # Remove in 6.3.
5
5
  PresentationTranslatable = LabelTranslatable
6
6
  end
@@ -241,8 +241,8 @@ module Spree
241
241
  # (docs/plans/6.0-volume-pricing.md).
242
242
  def self.with_currency(currency)
243
243
  joins(variants: :prices).
244
- where(Price.table_name => { currency: currency.upcase, price_list_id: nil }).
245
- where.not(Price.table_name => { amount: nil }).
244
+ where(Price.table_name => { currency: currency.upcase }).
245
+ merge(Price.listing).
246
246
  distinct
247
247
  end
248
248
 
@@ -207,8 +207,9 @@ module Spree
207
207
  return unless Spree::Events.enabled?
208
208
 
209
209
  @_current_event_name = event_name
210
- payload ||= event_payload_for(event_name)
211
- Spree::Events.publish(event_name, payload, metadata)
210
+ publish_in_event_store do
211
+ Spree::Events.publish(event_name, payload || event_payload_for(event_name), metadata)
212
+ end
212
213
  ensure
213
214
  @_current_event_name = nil
214
215
  end
@@ -389,7 +390,29 @@ module Spree
389
390
  end
390
391
 
391
392
  def capture_pre_destroy_payload
392
- @_pre_destroy_payload = event_payload
393
+ @_pre_destroy_payload = in_event_store { event_payload }
394
+ end
395
+
396
+ # Publishes with the record's own store, so the event is
397
+ # attributed to it rather than to whatever store the caller happens to
398
+ # be in — the default store, in a job or a rake task.
399
+ #
400
+ # Spree::Event reads Spree::Current lazily, so store_id is settled here
401
+ # while the context is still open: a subscriber job or a webhook
402
+ # delivery reads it long after.
403
+ def publish_in_event_store
404
+ in_event_store do
405
+ published = yield
406
+ published.store_id if published.is_a?(Spree::Event)
407
+ published
408
+ end
409
+ end
410
+
411
+ def in_event_store(&block)
412
+ store = (respond_to?(:store) ? self.store : nil) || Spree::Current.store
413
+ return block.call if store.nil? || store == Spree::Current.store
414
+
415
+ Spree::Current.with_store(store, &block)
393
416
  end
394
417
  end
395
418
  end
@@ -7,7 +7,7 @@ module Spree
7
7
  # of checkout addresses to the customer's defaults, and the ship→bill cloning
8
8
  # predicate. The shipping address is canonical: use_shipping copies it
9
9
  # onto the billing address; the reverse use_billing direction is a
10
- # deprecated 6.1-removal bridge. Clone callbacks are wired per model.
10
+ # deprecated 6.3-removal bridge. Clone callbacks are wired per model.
11
11
  module Addresses
12
12
  extend ActiveSupport::Concern
13
13
 
@@ -85,13 +85,16 @@ module Spree
85
85
  end
86
86
 
87
87
  # @deprecated The shipping address is canonical — use +use_shipping+ to
88
- # copy it onto the billing address. Removed in 6.1.
88
+ # copy it onto the billing address. Removed in 6.3.
89
89
  def use_billing=(value)
90
- Spree::Deprecation.warn('use_billing is deprecated and will be removed in Spree 6.1. The shipping address comes first — use use_shipping to copy it onto the billing address.')
90
+ Spree::Deprecation.warn(
91
+ 'use_billing is deprecated and will be removed in Spree 6.3. ' \
92
+ 'The shipping address comes first — use use_shipping to copy it onto the billing address.'
93
+ )
91
94
  @use_billing = value
92
95
  end
93
96
 
94
- # @deprecated See {#use_billing=}; removed in 6.1.
97
+ # @deprecated See {#use_billing=}; removed in 6.3.
95
98
  # @return [Boolean]
96
99
  def use_billing?
97
100
  use_billing.in?([true, 'true', '1'])
@@ -194,7 +197,7 @@ module Spree
194
197
  # customer's default ship address.
195
198
  #
196
199
  # @deprecated The shipping address is canonical (see {#use_billing=});
197
- # removed in 6.1 together with the use_billing bridge.
200
+ # removed in 6.3 together with the use_billing bridge.
198
201
  # @return [true]
199
202
  def clone_billing_address
200
203
  self.ship_address = bill_address if bill_address
@@ -4,7 +4,7 @@ module Spree
4
4
  # {Spree::Cart} and {Spree::Order}. Before 6.0 a cart was an incomplete
5
5
  # order, so extensions written against 5.x (payment gateways, checkout
6
6
  # plugins) call the legacy names on carts too. Every legacy name warns and
7
- # forwards to its replacement. Removed in 6.1.
7
+ # forwards to its replacement. Removed in 6.3.
8
8
  #
9
9
  # Renamed columns are also registered with +alias_attribute+, so the legacy
10
10
  # name keeps working in +where+ / +find_by+ (those paths do not warn).
@@ -80,7 +80,7 @@ module Spree
80
80
  private
81
81
 
82
82
  def warn_deprecated_name(legacy_name, current_name)
83
- Spree::Deprecation.warn("#{self.class.name}##{legacy_name} is deprecated and will be removed in Spree 6.1. Use ##{current_name} instead.")
83
+ Spree::Deprecation.warn("#{self.class.name}##{legacy_name} is deprecated and will be removed in Spree 6.3. Use ##{current_name} instead.")
84
84
  end
85
85
  end
86
86
  end
@@ -34,9 +34,11 @@ module Spree
34
34
  end
35
35
  end
36
36
 
37
- # @deprecated Use +default_country_code+. Removed in 6.1.
37
+ # @deprecated Use +default_country_code+. Removed in 6.3.
38
38
  def default_country_iso_code
39
- Spree::Deprecation.warn('Spree::Store#default_country_iso_code is deprecated, use #default_country_code instead')
39
+ Spree::Deprecation.warn(
40
+ 'Spree::Store#default_country_iso_code is deprecated and will be removed in Spree 6.3. Use #default_country_code instead.'
41
+ )
40
42
  default_country_code
41
43
  end
42
44
 
@@ -31,9 +31,12 @@ module Spree
31
31
  # it accepts to the customer's defaults on its own (see
32
32
  # Spree::Purchase::Addresses), and a guest who registers after placing
33
33
  # an order has that order's addresses adopted by Spree::Customers::Create.
34
- # Removed in Spree 6.1.
34
+ # Removed in Spree 6.3.
35
35
  def persist_order_address(order)
36
- Spree::Deprecation.warn('Spree::UserAddress#persist_order_address is deprecated and will be removed in Spree 6.1. Checkout already promotes the addresses it accepts to the customer\'s defaults.')
36
+ Spree::Deprecation.warn(
37
+ 'Spree::UserAddress#persist_order_address is deprecated and will be removed in Spree 6.3. ' \
38
+ "Checkout already promotes the addresses it accepts to the customer's defaults."
39
+ )
37
40
 
38
41
  # FIXME: we should check if the User's address is associated with country accepted by Store
39
42
  # if not we should try to find an address with valid country in User's address book
@@ -1,7 +1,7 @@
1
1
  module Spree
2
2
  # Deprecation alias for Spree::CustomerMethods, renamed from Spree::UserMethods in 6.0.
3
3
  # True constant alias — the underlying module, its associations, and prefix (cust)
4
- # are all Spree::CustomerMethods. Remove in Spree 6.1.
4
+ # are all Spree::CustomerMethods. Remove in Spree 6.3.
5
5
  UserMethods = CustomerMethods
6
- Spree::Deprecation.warn('Spree::UserMethods is deprecated and will be removed in Spree 6.1. Use Spree::CustomerMethods instead.')
6
+ Spree::Deprecation.warn('Spree::UserMethods is deprecated and will be removed in Spree 6.3. Use Spree::CustomerMethods instead.')
7
7
  end