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.
- checksums.yaml +4 -4
- data/app/jobs/spree/imports/create_rows_job.rb +4 -2
- data/app/jobs/spree/imports/process_rows_job.rb +4 -2
- data/app/jobs/spree/payments/handle_webhook_job.rb +12 -1
- data/app/jobs/spree/products/auto_match_taxons_job.rb +5 -2
- data/app/jobs/spree/search_provider/index_job.rb +8 -0
- data/app/jobs/spree/search_provider/remove_job.rb +3 -0
- data/app/jobs/spree/stock_locations/stock_items/create_job.rb +5 -2
- data/app/mailers/spree/base_mailer.rb +1 -1
- data/app/models/concerns/spree/acted_by.rb +2 -2
- data/app/models/concerns/spree/customer_methods.rb +6 -4
- data/app/models/concerns/spree/deprecated_customer_alias.rb +11 -3
- data/app/models/concerns/spree/derived_number.rb +1 -1
- data/app/models/concerns/spree/has_custom_fields.rb +16 -11
- data/app/models/concerns/spree/integrations_concern.rb +5 -3
- data/app/models/concerns/spree/label_translatable.rb +4 -4
- data/app/models/concerns/spree/metadata.rb +3 -3
- data/app/models/concerns/spree/personal_data_matching.rb +5 -1
- data/app/models/concerns/spree/presentation_translatable.rb +1 -1
- data/app/models/concerns/spree/product_scopes.rb +2 -2
- data/app/models/concerns/spree/publishable.rb +26 -3
- data/app/models/concerns/spree/purchase/addresses.rb +8 -5
- data/app/models/concerns/spree/purchase/deprecated_aliases.rb +2 -2
- data/app/models/concerns/spree/stores/markets.rb +4 -2
- data/app/models/concerns/spree/user_address.rb +5 -2
- data/app/models/concerns/spree/user_methods.rb +2 -2
- data/app/models/spree/address.rb +29 -14
- data/app/models/spree/asset.rb +3 -3
- data/app/models/spree/authentication/strategies/base_strategy.rb +10 -1
- data/app/models/spree/base.rb +1 -1
- data/app/models/spree/calculator/shipping/flat_rate.rb +6 -4
- data/app/models/spree/cart.rb +9 -4
- data/app/models/spree/category.rb +8 -6
- data/app/models/spree/classification.rb +2 -2
- data/app/models/spree/current.rb +19 -0
- data/app/models/spree/custom_field.rb +6 -6
- data/app/models/spree/custom_field_definition.rb +10 -7
- data/app/models/spree/delivery_method.rb +21 -15
- data/app/models/spree/delivery_rate.rb +1 -1
- data/app/models/spree/digital.rb +1 -1
- data/app/models/spree/digital_asset.rb +2 -2
- data/app/models/spree/digital_link.rb +4 -4
- data/app/models/spree/export.rb +29 -2
- data/app/models/spree/fulfillment/custom_events.rb +18 -10
- data/app/models/spree/fulfillment.rb +30 -23
- data/app/models/spree/fulfillment_item.rb +3 -3
- data/app/models/spree/fulfilment_changer.rb +1 -1
- data/app/models/spree/gift_card.rb +12 -12
- data/app/models/spree/import.rb +23 -15
- data/app/models/spree/import_row.rb +6 -6
- data/app/models/spree/inventory_unit.rb +1 -1
- data/app/models/spree/invitation.rb +14 -6
- data/app/models/spree/line_item.rb +10 -8
- data/app/models/spree/media.rb +27 -3
- data/app/models/spree/metafield.rb +1 -1
- data/app/models/spree/metafield_definition.rb +1 -1
- data/app/models/spree/metafields.rb +2 -2
- data/app/models/spree/option_type.rb +26 -0
- data/app/models/spree/option_value.rb +3 -3
- data/app/models/spree/order.rb +92 -46
- data/app/models/spree/order_inventory.rb +2 -2
- data/app/models/spree/order_merger.rb +2 -2
- data/app/models/spree/order_updater.rb +34 -20
- data/app/models/spree/payment.rb +8 -8
- data/app/models/spree/payment_method.rb +11 -9
- data/app/models/spree/price.rb +22 -8
- data/app/models/spree/price_list.rb +12 -6
- data/app/models/spree/price_rules/zone_rule.rb +1 -1
- data/app/models/spree/product.rb +32 -33
- data/app/models/spree/product_category.rb +10 -4
- data/app/models/spree/product_collection.rb +8 -1
- data/app/models/spree/promotion/rules/category.rb +27 -10
- data/app/models/spree/promotion/rules/country.rb +1 -1
- data/app/models/spree/promotion/rules/taxon.rb +4 -2
- data/app/models/spree/promotion/rules/user.rb +1 -1
- data/app/models/spree/promotion_action.rb +1 -1
- data/app/models/spree/promotion_rule_category.rb +5 -5
- data/app/models/spree/promotion_rule_taxon.rb +2 -2
- data/app/models/spree/prototype.rb +4 -1
- data/app/models/spree/return_authorization_reason.rb +3 -3
- data/app/models/spree/return_reason.rb +1 -1
- data/app/models/spree/search_provider/base.rb +2 -2
- data/app/models/spree/search_provider.rb +7 -5
- data/app/models/spree/seller.rb +93 -10
- data/app/models/spree/seller_requirements/complete_profile.rb +26 -7
- data/app/models/spree/shipment.rb +4 -1
- data/app/models/spree/shipping_method.rb +4 -1
- data/app/models/spree/shipping_rate.rb +1 -1
- data/app/models/spree/stock/coordinator.rb +2 -2
- data/app/models/spree/stock/estimator.rb +7 -5
- data/app/models/spree/stock/package.rb +10 -8
- data/app/models/spree/stock_item.rb +1 -1
- data/app/models/spree/stock_level/custom_events.rb +1 -1
- data/app/models/spree/stock_level.rb +31 -2
- data/app/models/spree/stock_location.rb +12 -8
- data/app/models/spree/stock_movement.rb +7 -6
- data/app/models/spree/stock_reservation.rb +5 -5
- data/app/models/spree/store.rb +42 -16
- data/app/models/spree/store_credit.rb +2 -2
- data/app/models/spree/store_credit_category.rb +5 -5
- data/app/models/spree/store_credit_type.rb +2 -2
- data/app/models/spree/subscriber.rb +7 -7
- data/app/models/spree/tax_rate.rb +5 -5
- data/app/models/spree/taxon.rb +3 -3
- data/app/models/spree/taxon_rule.rb +2 -2
- data/app/models/spree/taxonomy.rb +1 -1
- data/app/models/spree/variant.rb +12 -10
- data/app/models/spree/variant_media.rb +1 -1
- data/app/models/spree/wished_item.rb +1 -1
- data/app/models/spree/wishlist.rb +2 -2
- data/app/models/spree/wishlist_item/custom_events.rb +2 -2
- data/app/models/spree/zone.rb +1 -1
- data/app/models/spree/zone_member.rb +1 -1
- data/app/services/spree/carts/associate.rb +6 -2
- data/app/services/spree/carts/create.rb +1 -1
- data/app/services/spree/carts/destroy.rb +23 -7
- data/app/services/spree/carts/remove_item.rb +1 -1
- data/app/services/spree/carts/remove_line_item.rb +2 -2
- data/app/services/spree/carts/remove_out_of_stock_items.rb +3 -1
- data/app/services/spree/carts/set_quantity.rb +2 -2
- data/app/services/spree/carts/update.rb +17 -0
- data/app/services/spree/checkout/add_store_credit.rb +3 -3
- data/app/services/spree/checkout/remove_store_credit.rb +2 -2
- data/app/services/spree/collections/regenerate_products.rb +37 -15
- data/app/services/spree/companies/add_member.rb +9 -4
- data/app/services/spree/diagnostics/error_log.rb +139 -0
- data/app/services/spree/diagnostics/section.rb +72 -0
- data/app/services/spree/diagnostics/sections.rb +121 -0
- data/app/services/spree/diagnostics/stack.rb +73 -0
- data/app/services/spree/diagnostics.rb +132 -0
- data/app/services/spree/imports/row_processors/product_variant.rb +19 -0
- data/app/services/spree/newsletter/subscribe.rb +7 -3
- data/app/services/spree/orders/approve.rb +3 -3
- data/app/services/spree/orders/create_user_account.rb +2 -2
- data/app/services/spree/orders/remove_line_item.rb +16 -5
- data/app/services/spree/product_memberships.rb +21 -1
- data/app/services/spree/product_types/apply_to_products.rb +12 -2
- data/app/services/spree/products/auto_match_collections.rb +20 -4
- data/app/services/spree/products/auto_match_taxons.rb +5 -2
- data/app/services/spree/shipments/update.rb +2 -2
- data/app/services/spree/stock_locations/stock_items/create.rb +5 -2
- data/app/services/spree/stock_reservations/extend.rb +3 -1
- data/app/services/spree/stock_reservations/reserve.rb +12 -7
- data/app/services/spree/store_credits/apply.rb +9 -1
- data/app/services/spree/taxons/add_products.rb +4 -2
- data/app/services/spree/taxons/regenerate_products.rb +5 -2
- data/app/services/spree/taxons/remove_products.rb +4 -2
- data/app/services/spree/update_check.rb +7 -31
- data/app/tools/spree/agent_tools/describe_resource.rb +3 -0
- data/app/tools/spree/agent_tools/get_resource.rb +1 -1
- data/app/tools/spree/agent_tools/resource_write.rb +1 -1
- data/app/tools/spree/agent_tools/search_resources.rb +42 -10
- data/app/workflows/spree/carts/add_item.rb +52 -1
- data/app/workflows/spree/carts/complete.rb +14 -2
- data/app/workflows/spree/carts/recalculate.rb +1 -1
- data/app/workflows/spree/fulfillments/update.rb +1 -1
- data/app/workflows/spree/orders/cancel.rb +3 -1
- data/app/workflows/spree/payments/capture.rb +2 -2
- data/app/workflows/spree/payments/handle_webhook.rb +7 -3
- data/app/workflows/spree/seller_transfers/create.rb +1 -1
- data/app/workflows/spree/sellers/approve.rb +6 -0
- data/app/workflows/spree/sellers/create.rb +5 -2
- data/app/workflows/spree/stock_levels/bulk_upsert.rb +19 -7
- data/config/locales/be.yml +1 -1
- data/config/locales/en.yml +12 -0
- data/config/locales/fr.yml +1 -1
- data/config/locales/lt.yml +1 -1
- data/config/locales/ru.yml +1 -1
- data/config/locales/uk.yml +1 -1
- data/db/migrate/20240303174340_fix_spree_stock_item_unique_index.rb +14 -10
- data/db/migrate/20260710000001_rename_taxons_to_categories.rb +1 -1
- data/db/migrate/20260728000004_rename_shipping_to_fulfillment_and_delivery.rb +1 -1
- data/db/migrate/20260806000001_add_store_id_to_spree_tax_rates_and_categories.rb +1 -1
- data/db/migrate/20260807130001_add_country_state_codes_to_consumers.rb +1 -1
- data/db/migrate/20260809000001_rename_metafields_to_custom_fields.rb +1 -1
- data/db/migrate/20260809150001_promote_shipping_categories_to_delivery_profiles.rb +1 -1
- data/db/migrate/20260811000001_add_delivery_tracking_to_fulfillments.rb +1 -1
- data/db/migrate/20260814000001_rename_stock_items_to_stock_levels.rb +13 -7
- data/db/migrate/20260824000001_add_store_to_spree_media.rb +1 -1
- data/db/migrate/20260828100001_unify_import_and_export_tenancy.rb +1 -1
- data/db/migrate/20261016000001_remove_default_from_spree_tax_rates_included_in_price.rb +1 -1
- data/lib/spree/agent_tool.rb +3 -3
- data/lib/spree/agent_tools/default_catalog.rb +2 -2
- data/lib/spree/agent_tools/legacy_tools.rb +1 -1
- data/lib/spree/agent_tools/operation_tool.rb +1 -1
- data/lib/spree/agent_tools/record_summary.rb +8 -2
- data/lib/spree/agent_tools/resource_map.rb +82 -7
- data/lib/spree/core/dependencies.rb +10 -10
- data/lib/spree/core/engine.rb +14 -0
- data/lib/spree/core/number_generator.rb +4 -3
- data/lib/spree/core/preferences/preferable.rb +1 -1
- data/lib/spree/core/preferences/preferable_class_methods.rb +5 -1
- data/lib/spree/core/pricing/resolver.rb +2 -2
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core.rb +48 -10
- data/lib/spree/i18n.rb +6 -2
- data/lib/spree/localized_number.rb +1 -1
- data/lib/spree/removed_apis.rb +274 -0
- data/lib/spree/reporting/default_vocabulary.rb +26 -6
- data/lib/spree/testing_support/factories/digital_asset_factory.rb +1 -1
- data/lib/spree/testing_support/factories/stock_level_factory.rb +1 -1
- data/lib/spree/testing_support/factories/taxon_factory.rb +1 -1
- data/lib/spree/testing_support/factories/taxonomy_factory.rb +1 -1
- data/lib/spree/testing_support/factories/wishlist_item_factory.rb +1 -1
- data/lib/spree/testing_support/i18n.rb +7 -2
- data/lib/spree/testing_support/order_walkthrough.rb +5 -2
- data/lib/spree/upgrades/5_6_to_6_0/manifest.yml +14 -14
- data/lib/tasks/carts_migration.rake +1 -1
- data/lib/tasks/categories_and_collections.rake +1 -1
- data/lib/tasks/deliveries_migration.rake +1 -1
- data/lib/tasks/delivery_method_rules_migration.rake +1 -1
- data/lib/tasks/delivery_migration.rake +1 -1
- data/lib/tasks/delivery_profiles_migration.rake +2 -2
- data/lib/tasks/diagnostics.rake +11 -0
- data/lib/tasks/fold_store_credit_categories.rake +1 -1
- data/lib/tasks/migrate_country_state_codes.rake +1 -1
- data/lib/tasks/migrate_returns.rake +4 -4
- data/lib/tasks/migrate_rich_text_to_columns.rake +1 -1
- data/lib/tasks/store_settings.rake +1 -1
- data/lib/tasks/typed_stock_movements_migration.rake +1 -1
- metadata +13 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module Spree
|
|
2
|
-
# @deprecated Removed in Spree 6.
|
|
2
|
+
# @deprecated Removed in Spree 6.3 together with its table. Store credit no
|
|
3
3
|
# longer carries a category — the reason a credit exists lives in
|
|
4
4
|
# {Spree::StoreCredit#originator} (the return, exchange, claim or gift
|
|
5
5
|
# card that issued it) and in its free-text +memo+. The class stays only
|
|
@@ -12,22 +12,22 @@ module Spree
|
|
|
12
12
|
DEFAULT_NON_EXPIRING_TYPES = [GIFT_CARD_CATEGORY_NAME]
|
|
13
13
|
|
|
14
14
|
after_initialize do
|
|
15
|
-
Spree::Deprecation.warn('Spree::StoreCreditCategory is deprecated and will be removed in Spree 6.
|
|
15
|
+
Spree::Deprecation.warn('Spree::StoreCreditCategory is deprecated and will be removed in Spree 6.3. ' \
|
|
16
16
|
'Store credits no longer carry a category — use StoreCredit#originator and #memo instead.')
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
class << self
|
|
20
|
-
# @deprecated Removed in Spree 6.
|
|
20
|
+
# @deprecated Removed in Spree 6.3. Refund workflows no longer set a
|
|
21
21
|
# category on the store credit they issue.
|
|
22
22
|
def default_refund_category(_options = {})
|
|
23
|
-
Spree::Deprecation.warn('Spree::StoreCreditCategory.default_refund_category is deprecated and will be removed in Spree 6.
|
|
23
|
+
Spree::Deprecation.warn('Spree::StoreCreditCategory.default_refund_category is deprecated and will be removed in Spree 6.3. ' \
|
|
24
24
|
'Store credits no longer carry a category.')
|
|
25
25
|
first
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
# @deprecated use {.default_refund_category}
|
|
29
29
|
def default_reimbursement_category(options = {})
|
|
30
|
-
Spree::Deprecation.warn('Spree::StoreCreditCategory.default_reimbursement_category is deprecated and will be removed in Spree 6.
|
|
30
|
+
Spree::Deprecation.warn('Spree::StoreCreditCategory.default_reimbursement_category is deprecated and will be removed in Spree 6.3. ' \
|
|
31
31
|
'Store credits no longer carry a category.')
|
|
32
32
|
default_refund_category(options)
|
|
33
33
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module Spree
|
|
2
|
-
# @deprecated Removed in Spree 6.
|
|
2
|
+
# @deprecated Removed in Spree 6.3 together with its table. Nothing in Spree
|
|
3
3
|
# ever created a store credit type, so the +priority+ it was meant to
|
|
4
4
|
# provide never drove redemption order; store credits are now spent
|
|
5
5
|
# oldest first ({Spree::StoreCredit.oldest_first}). The class stays only so
|
|
@@ -11,7 +11,7 @@ module Spree
|
|
|
11
11
|
DEFAULT_TYPE_NAME = 'Expiring'.freeze
|
|
12
12
|
|
|
13
13
|
after_initialize do
|
|
14
|
-
Spree::Deprecation.warn('Spree::StoreCreditType is deprecated and will be removed in Spree 6.
|
|
14
|
+
Spree::Deprecation.warn('Spree::StoreCreditType is deprecated and will be removed in Spree 6.3. ' \
|
|
15
15
|
'Store credits are spent oldest first — see Spree::StoreCredit.oldest_first.')
|
|
16
16
|
end
|
|
17
17
|
end
|
|
@@ -11,7 +11,7 @@ module Spree
|
|
|
11
11
|
# class OrderCompletedNotifier < Spree::Subscriber
|
|
12
12
|
# subscribes_to 'order.placed'
|
|
13
13
|
#
|
|
14
|
-
# def
|
|
14
|
+
# def handle(event)
|
|
15
15
|
# order_id = event.payload['id']
|
|
16
16
|
# Spree::OrderMailer.confirm_email(order_id).deliver_later
|
|
17
17
|
# end
|
|
@@ -21,7 +21,7 @@ module Spree
|
|
|
21
21
|
# class OrderAuditLogger < Spree::Subscriber
|
|
22
22
|
# subscribes_to 'order.placed', 'order.canceled'
|
|
23
23
|
#
|
|
24
|
-
# def
|
|
24
|
+
# def handle(event)
|
|
25
25
|
# AuditLog.create!(
|
|
26
26
|
# event_name: event.name,
|
|
27
27
|
# payload: event.payload,
|
|
@@ -34,7 +34,7 @@ module Spree
|
|
|
34
34
|
# class OrderEventLogger < Spree::Subscriber
|
|
35
35
|
# subscribes_to 'order.*'
|
|
36
36
|
#
|
|
37
|
-
# def
|
|
37
|
+
# def handle(event)
|
|
38
38
|
# Rails.logger.info("Order event: #{event.name}")
|
|
39
39
|
# end
|
|
40
40
|
# end
|
|
@@ -66,7 +66,7 @@ module Spree
|
|
|
66
66
|
# class CriticalOrderHandler < Spree::Subscriber
|
|
67
67
|
# subscribes_to 'order.placed', async: false
|
|
68
68
|
#
|
|
69
|
-
# def
|
|
69
|
+
# def handle(event)
|
|
70
70
|
# # This runs synchronously
|
|
71
71
|
# end
|
|
72
72
|
# end
|
|
@@ -141,9 +141,9 @@ module Spree
|
|
|
141
141
|
|
|
142
142
|
# Handle an event
|
|
143
143
|
#
|
|
144
|
-
#
|
|
145
|
-
#
|
|
146
|
-
#
|
|
144
|
+
# Routes the event to the handler named with `on`, or to #handle.
|
|
145
|
+
# Subclasses implement #handle; overriding this method skips the
|
|
146
|
+
# `on` routing.
|
|
147
147
|
#
|
|
148
148
|
# @param event [Spree::Event] The event to handle
|
|
149
149
|
# @return [void]
|
|
@@ -8,7 +8,7 @@ module Spree
|
|
|
8
8
|
# Rates name their country and state directly since 6.0. No code reads
|
|
9
9
|
# zone_id any more, but the column stays in the database through 6.0: it is
|
|
10
10
|
# what `spree:migrate_tax_zones` converts from, and that task runs after
|
|
11
|
-
# db:migrate. The physical drop lands in 6.
|
|
11
|
+
# db:migrate. The physical drop lands in 6.3.
|
|
12
12
|
#
|
|
13
13
|
# The same goes for included_in_price: whether tax sits inside a price is
|
|
14
14
|
# the market's choice (Spree::Market#tax_inclusive), and the column is read
|
|
@@ -79,15 +79,15 @@ module Spree
|
|
|
79
79
|
self.amount = parsed && parsed / 100
|
|
80
80
|
end
|
|
81
81
|
|
|
82
|
-
# @deprecated Use {#rate_percent}; removed in 6.
|
|
82
|
+
# @deprecated Use {#rate_percent}; removed in 6.3.
|
|
83
83
|
def amount_percentage
|
|
84
|
-
Spree::Deprecation.warn('Spree::TaxRate#amount_percentage is deprecated and will be removed in Spree 6.
|
|
84
|
+
Spree::Deprecation.warn('Spree::TaxRate#amount_percentage is deprecated and will be removed in Spree 6.3. Use #rate_percent instead.')
|
|
85
85
|
rate_percent
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
-
# @deprecated Use {#rate_percent=}; removed in 6.
|
|
88
|
+
# @deprecated Use {#rate_percent=}; removed in 6.3.
|
|
89
89
|
def amount_percentage=(value)
|
|
90
|
-
Spree::Deprecation.warn('Spree::TaxRate#amount_percentage= is deprecated and will be removed in Spree 6.
|
|
90
|
+
Spree::Deprecation.warn('Spree::TaxRate#amount_percentage= is deprecated and will be removed in Spree 6.3. Use #rate_percent= instead.')
|
|
91
91
|
self.rate_percent = value
|
|
92
92
|
end
|
|
93
93
|
|
data/app/models/spree/taxon.rb
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
module Spree
|
|
4
4
|
# Deprecation alias for Spree::Category, renamed from Spree::Taxon in 6.0.
|
|
5
|
-
# Retained
|
|
5
|
+
# Retained until 6.3 so existing code and extensions that reference
|
|
6
6
|
# Spree::Taxon keep working; the canonical class is Spree::Category. Removed
|
|
7
|
-
# in 6.
|
|
7
|
+
# in 6.3 (along with the spree_taxonomies table and the automatic-taxon columns).
|
|
8
8
|
#
|
|
9
9
|
# This is a true constant alias — the underlying class, table (spree_categories),
|
|
10
10
|
# prefix (ctg), and model_name are all Spree::Category. Only the constant differs,
|
|
@@ -13,5 +13,5 @@ module Spree
|
|
|
13
13
|
# when this file loads (on first reference; it is kept out of eager loading).
|
|
14
14
|
Taxon = Category
|
|
15
15
|
|
|
16
|
-
Spree::Deprecation.warn('Spree::Taxon is deprecated and will be removed in Spree 6.
|
|
16
|
+
Spree::Deprecation.warn('Spree::Taxon is deprecated and will be removed in Spree 6.3. Use Spree::Category instead.')
|
|
17
17
|
end
|
|
@@ -10,7 +10,7 @@ module Spree
|
|
|
10
10
|
].freeze
|
|
11
11
|
|
|
12
12
|
# Category no longer declares the has_many :taxon_rules inverse (categories are
|
|
13
|
-
# manual in 6.0), so this is a plain belongs_to. Data-only until 6.
|
|
13
|
+
# manual in 6.0), so this is a plain belongs_to. Data-only until 6.3.
|
|
14
14
|
belongs_to :taxon, class_name: 'Spree::Category', touch: true
|
|
15
15
|
|
|
16
16
|
validates :type, :value, presence: true
|
|
@@ -19,7 +19,7 @@ module Spree
|
|
|
19
19
|
delegate :store, to: :taxon
|
|
20
20
|
|
|
21
21
|
# Retained as a data-only model in 6.0 so the taxons -> collections data
|
|
22
|
-
# migration can read existing automatic-taxon rules; dropped in 6.
|
|
22
|
+
# migration can read existing automatic-taxon rules; dropped in 6.3 along
|
|
23
23
|
# with the spree_taxon_rules table. Automatic membership now lives on
|
|
24
24
|
# Spree::Collection (rule matching + regeneration moved there).
|
|
25
25
|
end
|
|
@@ -4,7 +4,7 @@ module Spree
|
|
|
4
4
|
# spree_taxonomies table are retained solely so the 5.6 -> 6.0 upgrade task
|
|
5
5
|
# (spree:migrate_categories_and_collections) can read existing rows to
|
|
6
6
|
# backfill category store_id, and so an interrupted upgrade can be rolled
|
|
7
|
-
# back. Both drop in 6.
|
|
7
|
+
# back. Both drop in 6.3.
|
|
8
8
|
class Taxonomy < Spree.base_class
|
|
9
9
|
has_prefix_id :txnmy # Spree-specific: taxonomy
|
|
10
10
|
|
data/app/models/spree/variant.rb
CHANGED
|
@@ -546,21 +546,21 @@ module Spree
|
|
|
546
546
|
update_column(:primary_media_id, first_media&.id)
|
|
547
547
|
end
|
|
548
548
|
|
|
549
|
-
# @deprecated Read #gallery_media directly; removed in 6.
|
|
549
|
+
# @deprecated Read #gallery_media directly; removed in 6.3. Nothing in
|
|
550
550
|
# Spree calls this — a hover image is a storefront presentation choice,
|
|
551
551
|
# not something core should name.
|
|
552
552
|
# @return [Spree::Media, nil]
|
|
553
553
|
def secondary_image
|
|
554
|
-
Spree::Deprecation.warn('Spree::Variant#secondary_image is deprecated and will be removed in Spree 6.
|
|
554
|
+
Spree::Deprecation.warn('Spree::Variant#secondary_image is deprecated and will be removed in Spree 6.3. Use #gallery_media instead.')
|
|
555
555
|
gallery_media.second
|
|
556
556
|
end
|
|
557
557
|
|
|
558
|
-
# @deprecated Read #gallery_media directly; removed in 6.
|
|
558
|
+
# @deprecated Read #gallery_media directly; removed in 6.3. Nothing in
|
|
559
559
|
# Spree calls this, and which images to show beside the main one is a
|
|
560
560
|
# storefront presentation choice.
|
|
561
561
|
# @return [Array<Spree::Media>]
|
|
562
562
|
def additional_images
|
|
563
|
-
Spree::Deprecation.warn('Spree::Variant#additional_images is deprecated and will be removed in Spree 6.
|
|
563
|
+
Spree::Deprecation.warn('Spree::Variant#additional_images is deprecated and will be removed in Spree 6.3. Use #gallery_media instead.')
|
|
564
564
|
gallery_media.reject { |media| media.id == primary_media&.id }
|
|
565
565
|
end
|
|
566
566
|
|
|
@@ -752,15 +752,15 @@ module Spree
|
|
|
752
752
|
stock_levels.where.not(stock_location_id: location_ids_in_payload).destroy_all if persisted?
|
|
753
753
|
end
|
|
754
754
|
|
|
755
|
-
# @deprecated Use {#stock_levels}; removed in 6.
|
|
755
|
+
# @deprecated Use {#stock_levels}; removed in 6.3.
|
|
756
756
|
def stock_items
|
|
757
|
-
Spree::Deprecation.warn('Spree::Variant#stock_items is deprecated and will be removed in Spree 6.
|
|
757
|
+
Spree::Deprecation.warn('Spree::Variant#stock_items is deprecated and will be removed in Spree 6.3. Use #stock_levels instead.')
|
|
758
758
|
stock_levels
|
|
759
759
|
end
|
|
760
760
|
|
|
761
|
-
# @deprecated Use {#stock_levels=}; removed in 6.
|
|
761
|
+
# @deprecated Use {#stock_levels=}; removed in 6.3.
|
|
762
762
|
def stock_items=(value)
|
|
763
|
-
Spree::Deprecation.warn('Spree::Variant#stock_items= is deprecated and will be removed in Spree 6.
|
|
763
|
+
Spree::Deprecation.warn('Spree::Variant#stock_items= is deprecated and will be removed in Spree 6.3. Use #stock_levels= instead.')
|
|
764
764
|
self.stock_levels = value
|
|
765
765
|
end
|
|
766
766
|
|
|
@@ -788,9 +788,11 @@ module Spree
|
|
|
788
788
|
end
|
|
789
789
|
end
|
|
790
790
|
|
|
791
|
-
# @deprecated Use +stock_levels_attributes=+; removed in 6.
|
|
791
|
+
# @deprecated Use +stock_levels_attributes=+; removed in 6.3.
|
|
792
792
|
def stock_items_attributes=(value)
|
|
793
|
-
Spree::Deprecation.warn(
|
|
793
|
+
Spree::Deprecation.warn(
|
|
794
|
+
'Spree::Variant#stock_items_attributes= is deprecated and will be removed in Spree 6.3. Use #stock_levels_attributes= instead.'
|
|
795
|
+
)
|
|
794
796
|
self.stock_levels_attributes = value
|
|
795
797
|
end
|
|
796
798
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Spree
|
|
2
2
|
# FK column is `media_id`, matching Spree::Media and its table. The `:asset`
|
|
3
|
-
# association name stays readable
|
|
3
|
+
# association name stays readable until 6.3.
|
|
4
4
|
class VariantMedia < Spree.base_class
|
|
5
5
|
self.table_name = 'spree_variant_media'
|
|
6
6
|
|
|
@@ -30,9 +30,9 @@ module Spree
|
|
|
30
30
|
@wishlist_items_count ||= variant_ids.count
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
# @deprecated Use {#wishlist_items_count}; removed in 6.
|
|
33
|
+
# @deprecated Use {#wishlist_items_count}; removed in 6.3.
|
|
34
34
|
def wished_items_count
|
|
35
|
-
Spree::Deprecation.warn('Spree::Wishlist#wished_items_count is deprecated and will be removed in Spree 6.
|
|
35
|
+
Spree::Deprecation.warn('Spree::Wishlist#wished_items_count is deprecated and will be removed in Spree 6.3. Use #wishlist_items_count instead.')
|
|
36
36
|
wishlist_items_count
|
|
37
37
|
end
|
|
38
38
|
|
|
@@ -4,8 +4,8 @@ module Spree
|
|
|
4
4
|
class WishlistItem < Spree.base_class
|
|
5
5
|
# Dual-emits the pre-6.0 `wished_item.*` lifecycle events beside the
|
|
6
6
|
# `wishlist_item.*` ones, so a webhook endpoint a merchant configured
|
|
7
|
-
# against the old names keeps receiving deliveries
|
|
8
|
-
# Removed in 6.
|
|
7
|
+
# against the old names keeps receiving deliveries until 6.5.
|
|
8
|
+
# Removed in 6.5, the same way {Spree::StockLevel::CustomEvents} carries
|
|
9
9
|
# `stock_item.*`.
|
|
10
10
|
module CustomEvents
|
|
11
11
|
LEGACY_EVENT_PREFIX = 'wished_item'
|
data/app/models/spree/zone.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module Spree
|
|
2
|
-
# Migration-only shell, removed in Spree 6.
|
|
2
|
+
# Migration-only shell, removed in Spree 6.3: rows survive solely as source
|
|
3
3
|
# data for the 5.6→6.0 zone, market and tax migrations. Countries and states
|
|
4
4
|
# are reference data in 6.0, so member ids resolve against the legacy tables
|
|
5
5
|
# rather than through associations.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module Spree
|
|
2
|
-
# Migration-only shell, removed in Spree 6.
|
|
2
|
+
# Migration-only shell, removed in Spree 6.3 with {Spree::Zone}.
|
|
3
3
|
class ZoneMember < Spree.base_class
|
|
4
4
|
# No zoneable association: countries and states are reference data in 6.0,
|
|
5
5
|
# so the type and id columns are plain values resolved against the legacy
|
|
@@ -5,11 +5,15 @@ module Spree
|
|
|
5
5
|
|
|
6
6
|
def call(guest_cart: nil, guest_order: nil, customer: nil, user: nil, override_email: true, guest_only: false)
|
|
7
7
|
if guest_order
|
|
8
|
-
Spree::Deprecation.warn(
|
|
8
|
+
Spree::Deprecation.warn(
|
|
9
|
+
'Calling Spree::Carts::Associate with guest_order: is deprecated and will be removed in Spree 6.3. Pass guest_cart: instead.'
|
|
10
|
+
)
|
|
9
11
|
guest_cart ||= guest_order
|
|
10
12
|
end
|
|
11
13
|
if user && customer.nil?
|
|
12
|
-
Spree::Deprecation.warn(
|
|
14
|
+
Spree::Deprecation.warn(
|
|
15
|
+
'Calling Spree::Carts::Associate with user: is deprecated and will be removed in Spree 6.3. Pass customer: instead.'
|
|
16
|
+
)
|
|
13
17
|
customer = user
|
|
14
18
|
end
|
|
15
19
|
return failure(guest_cart, 'Already assigned to a customer') if guest_only && guest_cart.customer.present? && guest_cart.customer != customer
|
|
@@ -11,7 +11,7 @@ module Spree
|
|
|
11
11
|
|
|
12
12
|
customer = @params.delete(:customer)
|
|
13
13
|
if @params.key?(:user)
|
|
14
|
-
Spree::Deprecation.warn('Passing user: to Spree::Carts::Create is deprecated and will be removed in Spree 6.
|
|
14
|
+
Spree::Deprecation.warn('Passing user: to Spree::Carts::Create is deprecated and will be removed in Spree 6.3. Pass customer: instead.')
|
|
15
15
|
customer ||= @params.delete(:user)
|
|
16
16
|
end
|
|
17
17
|
|
|
@@ -3,23 +3,39 @@ module Spree
|
|
|
3
3
|
class Destroy
|
|
4
4
|
prepend Spree::ServiceModule::Base
|
|
5
5
|
|
|
6
|
+
# Destroys a deletable cart while serializing against checkout completion.
|
|
7
|
+
# Live completion claims leave the cart and its dependent records intact.
|
|
8
|
+
#
|
|
9
|
+
# @param cart [Spree::Cart, nil] cart to abandon
|
|
10
|
+
# @param order [Spree::Cart, Spree::Order, nil] deprecated input alias
|
|
11
|
+
# @return [Spree::ServiceModule::Result] deletion outcome
|
|
6
12
|
def call(cart: nil, order: nil)
|
|
7
13
|
if order
|
|
8
|
-
Spree::Deprecation.warn('Calling Spree::Carts::Destroy with order: is deprecated and will be removed in Spree 6.
|
|
14
|
+
Spree::Deprecation.warn('Calling Spree::Carts::Destroy with order: is deprecated and will be removed in Spree 6.3. Pass cart: instead.')
|
|
9
15
|
cart ||= order
|
|
10
16
|
end
|
|
11
17
|
rewrite_input!(remove: [:order], cart: cart)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
return failure(false, I18n.t('spree.cannot_be_destroyed')) unless cart
|
|
19
|
+
|
|
20
|
+
cart.with_lock do
|
|
21
|
+
run :check_if_can_be_destroyed
|
|
22
|
+
run :cancel_shipments
|
|
23
|
+
run :release_gift_card
|
|
24
|
+
run :void_payments
|
|
25
|
+
run :clear_addresses
|
|
26
|
+
run :destroy_order
|
|
27
|
+
end
|
|
18
28
|
end
|
|
19
29
|
|
|
20
30
|
private
|
|
21
31
|
|
|
32
|
+
# Refuses live completion claims and settled purchases before destructive steps.
|
|
33
|
+
#
|
|
34
|
+
# @param cart [Spree::Cart, Spree::Order] purchase being checked
|
|
35
|
+
# @return [Spree::ServiceModule::Result] deletion eligibility
|
|
22
36
|
def check_if_can_be_destroyed(cart:)
|
|
37
|
+
return failure(false, I18n.t('spree.cart_completion_in_progress')) if cart.is_a?(Spree::Cart) && cart.completion_claimed?
|
|
38
|
+
|
|
23
39
|
return failure(false, I18n.t('spree.cannot_be_destroyed')) unless cart&.can_be_deleted?
|
|
24
40
|
|
|
25
41
|
success(cart: cart)
|
|
@@ -5,7 +5,7 @@ module Spree
|
|
|
5
5
|
|
|
6
6
|
def call(cart: nil, order: nil, variant: nil, quantity: nil, options: nil)
|
|
7
7
|
if order
|
|
8
|
-
Spree::Deprecation.warn('Calling Spree::Carts::RemoveItem with order: is deprecated and will be removed in Spree 6.
|
|
8
|
+
Spree::Deprecation.warn('Calling Spree::Carts::RemoveItem with order: is deprecated and will be removed in Spree 6.3. Pass cart: instead.')
|
|
9
9
|
cart ||= order
|
|
10
10
|
end
|
|
11
11
|
options ||= {}
|
|
@@ -3,7 +3,7 @@ module Spree
|
|
|
3
3
|
# @deprecated Removing an item is an upsert with quantity zero. Call
|
|
4
4
|
# Spree::Carts::UpsertItems so the removal passes the same
|
|
5
5
|
# 'carts.upsert_items.validate' hook every other item mutation does.
|
|
6
|
-
# Removed in Spree 6.
|
|
6
|
+
# Removed in Spree 6.3.
|
|
7
7
|
class RemoveLineItem
|
|
8
8
|
prepend Spree::ServiceModule::Base
|
|
9
9
|
|
|
@@ -11,7 +11,7 @@ module Spree
|
|
|
11
11
|
# the upsert path identifies the row by variant, not by line-item options.
|
|
12
12
|
def call(cart: nil, order: nil, line_item: nil, options: nil)
|
|
13
13
|
Spree::Deprecation.warn(
|
|
14
|
-
'Spree::Carts::RemoveLineItem is deprecated and will be removed in Spree 6.
|
|
14
|
+
'Spree::Carts::RemoveLineItem is deprecated and will be removed in Spree 6.3. ' \
|
|
15
15
|
'Use Spree::Carts::UpsertItems with quantity: 0 instead. Note it removes the ' \
|
|
16
16
|
'cart\'s line item for the variant, which is this one unless the cart holds ' \
|
|
17
17
|
'several rows of the same variant.'
|
|
@@ -5,7 +5,9 @@ module Spree
|
|
|
5
5
|
|
|
6
6
|
def call(cart: nil, order: nil)
|
|
7
7
|
if order
|
|
8
|
-
Spree::Deprecation.warn(
|
|
8
|
+
Spree::Deprecation.warn(
|
|
9
|
+
'Calling Spree::Carts::RemoveOutOfStockItems with order: is deprecated and will be removed in Spree 6.3. Pass cart: instead.'
|
|
10
|
+
)
|
|
9
11
|
cart ||= order
|
|
10
12
|
end
|
|
11
13
|
@messages = []
|
|
@@ -3,13 +3,13 @@ module Spree
|
|
|
3
3
|
# @deprecated Setting a quantity is a one-item upsert. Call
|
|
4
4
|
# Spree::Carts::UpsertItems so the change passes the same
|
|
5
5
|
# 'carts.upsert_items.validate' hook every other item mutation does.
|
|
6
|
-
# Removed in Spree 6.
|
|
6
|
+
# Removed in Spree 6.3.
|
|
7
7
|
class SetQuantity
|
|
8
8
|
prepend Spree::ServiceModule::Base
|
|
9
9
|
|
|
10
10
|
def call(cart: nil, order: nil, line_item: nil, quantity: nil)
|
|
11
11
|
Spree::Deprecation.warn(
|
|
12
|
-
'Spree::Carts::SetQuantity is deprecated and will be removed in Spree 6.
|
|
12
|
+
'Spree::Carts::SetQuantity is deprecated and will be removed in Spree 6.3. ' \
|
|
13
13
|
'Use Spree::Carts::UpsertItems (quantity is set, not added) instead.'
|
|
14
14
|
)
|
|
15
15
|
owner = cart || order
|
|
@@ -56,6 +56,13 @@ module Spree
|
|
|
56
56
|
failure(cart, e.message)
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
+
# Fields assign_cart_attributes handles itself; an extension can't
|
|
60
|
+
# reroute them through a plain assignment.
|
|
61
|
+
CORE_ATTRIBUTES = %i[
|
|
62
|
+
email customer_note po_number market_id currency locale metadata use_shipping
|
|
63
|
+
preferred_stock_location_id company_id po_document_signed_id
|
|
64
|
+
].freeze
|
|
65
|
+
|
|
59
66
|
private
|
|
60
67
|
|
|
61
68
|
attr_reader :cart, :params
|
|
@@ -79,6 +86,7 @@ module Spree
|
|
|
79
86
|
end
|
|
80
87
|
|
|
81
88
|
def assign_cart_attributes
|
|
89
|
+
assign_additional_attributes
|
|
82
90
|
cart.email = params[:email] if params[:email].present?
|
|
83
91
|
cart.customer_note = params[:customer_note] if params.key?(:customer_note)
|
|
84
92
|
cart.po_number = params[:po_number] if params.key?(:po_number)
|
|
@@ -93,6 +101,15 @@ module Spree
|
|
|
93
101
|
assign_po_document if params.key?(:po_document_signed_id)
|
|
94
102
|
end
|
|
95
103
|
|
|
104
|
+
# Columns an extension made writable with
|
|
105
|
+
# `Spree::Cart.additional_permitted_attributes += [...]`.
|
|
106
|
+
def assign_additional_attributes
|
|
107
|
+
keys = Array(Spree::Cart.try(:additional_permitted_attributes)).
|
|
108
|
+
flat_map { |attribute| attribute.is_a?(Hash) ? attribute.keys : attribute }.
|
|
109
|
+
map(&:to_sym) - CORE_ATTRIBUTES
|
|
110
|
+
cart.assign_attributes(params.slice(*keys)) if keys.any?
|
|
111
|
+
end
|
|
112
|
+
|
|
96
113
|
# The buyer's purchase order as an ActiveStorage signed blob id — the
|
|
97
114
|
# bytes are normally already in storage by the time this runs. A blank
|
|
98
115
|
# value detaches, so a buyer can withdraw a document they attached in
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
module Spree
|
|
2
2
|
module Checkout
|
|
3
3
|
# Deprecation alias for Spree::StoreCredits::Apply, renamed in 6.0 for
|
|
4
|
-
# symmetry with Spree::GiftCards::Apply. Retained
|
|
4
|
+
# symmetry with Spree::GiftCards::Apply. Retained until 6.3 so existing
|
|
5
5
|
# code and extensions keep working. A constant assignment rather than a
|
|
6
6
|
# subclass, so is_a? and class_name: references keep resolving; the file
|
|
7
|
-
# is named for the constant because Zeitwerk requires it. Removed in 6.
|
|
7
|
+
# is named for the constant because Zeitwerk requires it. Removed in 6.3.
|
|
8
8
|
AddStoreCredit = Spree::StoreCredits::Apply
|
|
9
9
|
|
|
10
10
|
Spree::Deprecation.warn(
|
|
11
|
-
'Spree::Checkout::AddStoreCredit is deprecated and will be removed in Spree 6.
|
|
11
|
+
'Spree::Checkout::AddStoreCredit is deprecated and will be removed in Spree 6.3. ' \
|
|
12
12
|
'Use Spree::StoreCredits::Apply instead.'
|
|
13
13
|
)
|
|
14
14
|
end
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
module Spree
|
|
2
2
|
module Checkout
|
|
3
3
|
# Deprecation alias for Spree::StoreCredits::Remove — see
|
|
4
|
-
# Spree::Checkout::AddStoreCredit. Removed in 6.
|
|
4
|
+
# Spree::Checkout::AddStoreCredit. Removed in 6.3.
|
|
5
5
|
RemoveStoreCredit = Spree::StoreCredits::Remove
|
|
6
6
|
|
|
7
7
|
Spree::Deprecation.warn(
|
|
8
|
-
'Spree::Checkout::RemoveStoreCredit is deprecated and will be removed in Spree 6.
|
|
8
|
+
'Spree::Checkout::RemoveStoreCredit is deprecated and will be removed in Spree 6.3. ' \
|
|
9
9
|
'Use Spree::StoreCredits::Remove instead.'
|
|
10
10
|
)
|
|
11
11
|
end
|
|
@@ -12,24 +12,36 @@ module Spree
|
|
|
12
12
|
return if collection.destroyed?
|
|
13
13
|
return if collection.manual?
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
# Loaded rather than plucked: a row dropped below is gone by the time
|
|
16
|
+
# its deleted event can be published, so it has to be held.
|
|
17
|
+
previous_rows = collection.product_collections.order(position: :asc).to_a
|
|
18
|
+
previous_products_ids = previous_rows.map(&:product_id)
|
|
19
|
+
matching_ids = collection.products_matching_rules.ids
|
|
20
|
+
matching = matching_ids.to_set
|
|
16
21
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
Spree::ProductCollection.where(collection_id: collection.id).delete_all
|
|
22
|
+
retained_rows = previous_rows.select { |row| matching.include?(row.product_id) }
|
|
23
|
+
removed_rows = previous_rows - retained_rows
|
|
24
|
+
added_ids = matching_ids - previous_products_ids
|
|
21
25
|
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
# Hard-delete (no callbacks). Class-level delete rather than the
|
|
27
|
+
# association proxy, which under `dependent: :destroy_async` doesn't
|
|
28
|
+
# reliably remove rows here.
|
|
29
|
+
Spree::ProductCollection.where(id: removed_rows.map(&:id)).delete_all if removed_rows.any?
|
|
24
30
|
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
# Close the gaps the removals left, keeping the survivors in the order
|
|
32
|
+
# they were already in. One statement rather than one per row:
|
|
33
|
+
# dropping an early member shifts every row behind it.
|
|
34
|
+
moved = retained_rows.each_with_index.filter_map do |row, index|
|
|
35
|
+
next if row.position == index + 1
|
|
27
36
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
37
|
+
{ id: row.id, collection_id: collection.id, product_id: row.product_id,
|
|
38
|
+
position: index + 1, created_at: row.created_at, updated_at: Time.current }
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
Spree::ProductCollection.upsert_all(moved, unique_by: (:id unless Spree.mysql?)) if moved.any?
|
|
32
42
|
|
|
43
|
+
if added_ids.any?
|
|
44
|
+
records_to_insert = added_ids.map.with_index(retained_rows.size + 1) do |product_id, position|
|
|
33
45
|
product_collection_attributes(product_id, collection, position)
|
|
34
46
|
end
|
|
35
47
|
|
|
@@ -38,19 +50,29 @@ module Spree
|
|
|
38
50
|
|
|
39
51
|
# Expire cache + reindex the union of previous and new members, so products
|
|
40
52
|
# dropped when the match set empties also refresh their stale collection_ids.
|
|
41
|
-
products = Spree::Product.where(id: (previous_products_ids +
|
|
53
|
+
products = Spree::Product.where(id: (previous_products_ids + matching_ids).uniq)
|
|
42
54
|
products.touch_all
|
|
43
55
|
products.each(&:enqueue_search_index)
|
|
44
56
|
|
|
45
57
|
# counter caches — bulk insert/delete bypass the ProductCollection counter_cache callbacks
|
|
46
58
|
Spree::Collection.reset_counters(collection.id, :product_collections)
|
|
47
|
-
Spree::Product.reset_counters_in_bulk(previous_products_ids +
|
|
59
|
+
Spree::Product.reset_counters_in_bulk(previous_products_ids + matching_ids, :product_collections)
|
|
60
|
+
|
|
61
|
+
publish_membership_events(collection, removed_rows, added_ids)
|
|
48
62
|
|
|
49
63
|
success(collection)
|
|
50
64
|
end
|
|
51
65
|
|
|
52
66
|
private
|
|
53
67
|
|
|
68
|
+
def publish_membership_events(collection, removed_rows, added_ids)
|
|
69
|
+
removed_rows.each { |row| row.publish_event('product_collection.deleted') }
|
|
70
|
+
return if added_ids.empty?
|
|
71
|
+
|
|
72
|
+
Spree::ProductCollection.where(collection_id: collection.id, product_id: added_ids).
|
|
73
|
+
find_each { |row| row.publish_event('product_collection.created') }
|
|
74
|
+
end
|
|
75
|
+
|
|
54
76
|
def product_collection_attributes(product_id, collection, position)
|
|
55
77
|
{
|
|
56
78
|
product_id: product_id,
|
|
@@ -11,7 +11,10 @@ module Spree
|
|
|
11
11
|
prepend Spree::ServiceModule::Base
|
|
12
12
|
|
|
13
13
|
# @param company [Spree::Company]
|
|
14
|
-
# @param email [String]
|
|
14
|
+
# @param email [String, nil] who to add, when no +customer+ is given
|
|
15
|
+
# @param customer [Spree.customer_class, nil] an existing customer, who
|
|
16
|
+
# becomes a member immediately — for a caller that picked them rather
|
|
17
|
+
# than typed an address
|
|
15
18
|
# @param inviter [Object, nil] the inviting customer, nil when staff
|
|
16
19
|
# @param metadata [Hash, nil] extension payload — carried on the
|
|
17
20
|
# invitation only, where Enterprise reads it back on acceptance
|
|
@@ -26,9 +29,11 @@ module Spree
|
|
|
26
29
|
# whoever happens to hold that email.
|
|
27
30
|
# @return [Spree::ServiceModule::Result] value is the created
|
|
28
31
|
# Spree::CompanyMembership or Spree::CompanyInvitation
|
|
29
|
-
def call(company:, email
|
|
30
|
-
normalized_email = email.to_s.strip.downcase
|
|
31
|
-
customer
|
|
32
|
+
def call(company:, email: nil, customer: nil, inviter: nil, metadata: nil, require_acceptance: false)
|
|
33
|
+
normalized_email = (email.presence || customer&.email).to_s.strip.downcase
|
|
34
|
+
# Acceptance outranks a customer handed in: they are invited by their
|
|
35
|
+
# address like anyone else, so only the holder can agree to join.
|
|
36
|
+
customer = require_acceptance ? nil : (customer || Spree.customer_class.find_by(email: normalized_email))
|
|
32
37
|
|
|
33
38
|
record =
|
|
34
39
|
if customer
|