reload line items and recalculate fees after removing line item

This commit is contained in:
Andy Brett
2021-03-17 11:33:27 -07:00
parent 12b66d82ab
commit 70b7143e7b
2 changed files with 7 additions and 3 deletions

View File

@@ -62,7 +62,12 @@ class SubscriptionPlacementJob < ActiveJob::Base
unavailable_stock_lines_for(order).each do |line_item|
changes[line_item.id] = changes[line_item.id] || line_item.quantity
line_item.update(quantity: 0)
Spree::OrderInventory.new(order).verify(line_item)
Spree::OrderInventory.new(order).verify(line_item, order.shipment)
end
if changes.present?
order.line_items.reload
order.update_order_fees!
end
changes
end

View File

@@ -98,8 +98,7 @@ module Spree
inventory_unit.destroy
removed_quantity += 1
end
shipment.destroy if shipment.inventory_units.count == 0
shipment.destroy if shipment.inventory_units.reload.count == 0
# removing this from shipment, and adding to stock_location
if order.completed?