Skip to content

Commit

Permalink
Merge pull request #4138 from aldesantis/replaceable-order-classes
Browse files Browse the repository at this point in the history
Make order-related service objects configurable
  • Loading branch information
kennyadsl authored Aug 9, 2021
2 parents 24bf333 + f72ab4d commit 64ec398
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
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

0 comments on commit 64ec398

Please sign in to comment.