Module: SpreeCmCommissioner::Cart::EmptyDecorator
- Defined in:
- app/services/spree_cm_commissioner/cart/empty_decorator.rb
Instance Method Summary collapse
-
#call(order:) ⇒ Object
Emptying the cart removes all line items, so any inventory/seat holds must be released first — reversed against the quantities the hold was placed against (Release reads live line items).
Instance Method Details
#call(order:) ⇒ Object
Emptying the cart removes all line items, so any inventory/seat holds must be released first — reversed against the quantities the hold was placed against (Release reads live line items). Skip completed orders (Cart::Empty refuses them anyway, and their holds are already converted, not active). Guard on success and abort if the release fails.
9 10 11 12 13 14 15 16 |
# File 'app/services/spree_cm_commissioner/cart/empty_decorator.rb', line 9 def call(order:) if order.present? && !order.completed? release = order.release_order_holds(reason: :cart_changed) return release unless release.success? end super end |