Module: SpreeCmCommissioner::Cart::AddItemDecorator
- Defined in:
- app/services/spree_cm_commissioner/cart/add_item_decorator.rb
Instance Method Summary collapse
-
#call(order:) ⇒ Object
Release the order’s holds BEFORE mutating the cart, so the hold is reversed using the quantities it was actually placed against (Release reads live line items, it stores no snapshot).
Instance Method Details
#call(order:) ⇒ Object
Release the order’s holds BEFORE mutating the cart, so the hold is reversed using the quantities it was actually placed against (Release reads live line items, it stores no snapshot). Releasing after the change would restock the wrong amounts. A fresh hold is re-acquired when the order transitions toward checkout. Guard on success: if the release fails, abort and surface the error — the cart stays untouched.
10 11 12 13 14 15 |
# File 'app/services/spree_cm_commissioner/cart/add_item_decorator.rb', line 10 def call(order:, **) release = order.release_order_holds(reason: :cart_changed) return release unless release.success? super end |