Class: Spree::OrderContents
- Inherits:
-
SimpleOrderContents
- Object
- SimpleOrderContents
- Spree::OrderContents
- Defined in:
- app/models/spree/order_contents.rb
Instance Method Summary collapse
-
#update_cart(params) ⇒ Object
Updates the order’s line items with the params passed in.
Instance Method Details
#update_cart(params) ⇒ Object
Updates the order’s line items with the params passed in. Also runs the PromotionHandler::Cart.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/spree/order_contents.rb', line 7 def update_cart(params) if order.update(params) unless order.completed? order.line_items = order.line_items.select { |li| li.quantity > 0 } # Update totals, then check if the order is eligible for any cart promotions. # If we do not update first, then the item total will be wrong and ItemTotal # promotion rules would not be triggered. reload_totals order.check_shipments_and_restart_checkout ::Spree::PromotionHandler::Cart.new(order).activate end reload_totals true else false end end |