Module: SpreeCmCommissioner::Cart::RecalculateDecorator
- Defined in:
- app/services/spree_cm_commissioner/cart/recalculate_decorator.rb
Instance Method Summary collapse
Instance Method Details
#call(order:, line_item:, line_item_created: false, options: {}) ⇒ Object
override
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/services/spree_cm_commissioner/cart/recalculate_decorator.rb', line 5 def call(order:, line_item:, line_item_created: false, options: {}) # recaculate is called after update quantity, add or remove line items. # order should be reload before recaculate to avoid wrong caculation. order.reload # SPREE: Original Spree::Cart::Recalculate code starts here order_updater = ::Spree::OrderUpdater.new(order) order.payments.store_credits.checkout.destroy_all order_updater.update shipment = [:shipment] if shipment.present? # ADMIN END SHIPMENT RATE FIX # refresh shipments to ensure correct shipment amount is calculated when using price sack calculator # for calculating shipment rates. # Currently shipment rate is calculated on previous order total instead of current order total when updating a shipment from admin end. order.refresh_shipment_rates(::Spree::ShippingMethod::DISPLAY_ON_BACK_END) shipment.update_amounts else order.ensure_updated_shipments end # SPREE: Original Spree::Cart::Recalculate code ends here ::Spree::PromotionHandler::Cart.new(order, line_item).activate ::Spree::Adjustable::AdjustmentsUpdater.update(line_item) ::Spree::TaxRate.adjust(order, [line_item.reload]) if line_item_created order_updater.update success(line_item) end |