Class: Spree::Cart::Update
- Inherits:
-
Object
- Object
- Spree::Cart::Update
- Includes:
- ServiceModule::Base
- Defined in:
- app/services/spree/cart/update.rb
Instance Method Summary collapse
Methods included from ServiceModule::Base
Instance Method Details
#call(order:, params:) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/services/spree/cart/update.rb', line 6 def call(order:, params:) return failure(order) unless order.update(filter_order_items(order, params)) 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. ActiveRecord::Base.transaction do order.update_with_updater! ::Spree::PromotionHandler::Cart.new(order).activate order.ensure_updated_shipments order.payments.store_credits.checkout.destroy_all order.update_with_updater! end success(order) end |