Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make order-related service objects configurable #4138

Merged
merged 3 commits into from
Aug 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions core/app/models/spree/order.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,15 +269,15 @@ def all_inventory_units_returned?
end

def contents
@contents ||= Spree::OrderContents.new(self)
@contents ||= Spree::Config.order_contents_class.new(self)
end

def shipping
@shipping ||= Spree::OrderShipping.new(self)
@shipping ||= Spree::Config.order_shipping_class.new(self)
end

def cancellations
@cancellations ||= Spree::OrderCancellations.new(self)
@cancellations ||= Spree::Config.order_cancellations_class.new(self)
end

# Associates the specified user with the order.
Expand Down
22 changes: 22 additions & 0 deletions core/lib/spree/app_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,28 @@ def default_pricing_options
# Spree::Wallet::DefaultPaymentBuilder.
class_name_attribute :default_payment_builder_class, default: 'Spree::Wallet::DefaultPaymentBuilder'

# Allows providing your own class for managing the contents of an order.
#
# @!attribute [rw] order_contents_class
# @return [Class] a class with the same public interfaces as
# Spree::OrderContents.
class_name_attribute :order_contents_class, default: 'Spree::OrderContents'

# Allows providing your own class for shipping an order.
#
# @!attribute [rw] order_shipping_class
# @return [Class] a class with the same public interfaces as
# Spree::OrderShipping.
class_name_attribute :order_shipping_class, default: 'Spree::OrderShipping'

# Allows providing your own class for managing the inventory units of a
# completed order.
#
# @!attribute [rw] order_cancellations_class
# @return [Class] a class with the same public interfaces as
# Spree::OrderCancellations.
class_name_attribute :order_cancellations_class, default: 'Spree::OrderCancellations'

# Allows providing your own class for canceling payments.
#
# @!attribute [rw] payment_canceller
Expand Down