Use OrderContents when removing line items with soft-deleted variants in CartService

This commit is contained in:
Matt-Yorkley
2021-05-11 13:39:53 +01:00
parent 7af5e8931f
commit 6451ef173c

View File

@@ -37,7 +37,7 @@ class CartService
loaded_variant = loaded_variants[variant_data[:variant_id].to_i]
if loaded_variant.deleted?
remove_deleted_variant(loaded_variant)
order.contents.remove(loaded_variant)
next
end
@@ -57,10 +57,6 @@ class CartService
end
end
def remove_deleted_variant(variant)
line_item_for_variant(variant).andand.destroy
end
def attempt_cart_add(variant, quantity, max_quantity = nil)
quantity = quantity.to_i
max_quantity = max_quantity.to_i if max_quantity