mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-10 23:07:47 +00:00
Update line item removal in CartService when the line item doesn't exist
This commit is contained in:
@@ -36,7 +36,7 @@ class CartService
|
||||
loaded_variant = loaded_variants[variant_data[:variant_id]]
|
||||
|
||||
if loaded_variant.deleted? || !variant_data[:quantity].positive?
|
||||
order.contents.remove(loaded_variant)
|
||||
cart_remove(loaded_variant)
|
||||
next
|
||||
end
|
||||
|
||||
@@ -69,7 +69,15 @@ class CartService
|
||||
if attributes[:quantity].positive?
|
||||
@order.contents.update_or_create(variant, attributes)
|
||||
else
|
||||
@order.contents.remove(variant)
|
||||
cart_remove(variant)
|
||||
end
|
||||
end
|
||||
|
||||
def cart_remove(variant)
|
||||
begin
|
||||
order.contents.remove(variant)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
# Nothing to remove; no line items for this variant were found.
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user