Use OrderContents in LineItemsController and move enterprise fee updating logic

This commit is contained in:
Matt-Yorkley
2021-05-11 18:15:08 +01:00
parent a883b2cf63
commit f5c08baabb
3 changed files with 2 additions and 5 deletions

View File

@@ -81,7 +81,6 @@ module Api
quantity = params[:quantity].to_i
@order.contents.remove(variant, quantity, @shipment)
@order.recreate_all_fees!
@shipment.reload if @shipment.persisted?
render json: @shipment, serializer: Api::ShipmentSerializer, status: :ok

View File

@@ -39,12 +39,9 @@ class LineItemsController < BaseController
def destroy_with_lock(item)
order = item.order
order.with_lock do
item.destroy
order.contents.remove(item.variant)
order.update_shipping_fees!
order.update_payment_fees!
order.update_order_fees!
order.update_order!
order.create_tax_charge!
end
end
end

View File

@@ -22,6 +22,7 @@ module Spree
def remove(variant, quantity = nil, shipment = nil)
line_item = remove_from_line_item(variant, quantity, shipment)
update_shipment(shipment)
order.update_order_fees! if order.completed?
update_order
line_item
end