mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-06 02:51:34 +00:00
After adding an item to the cart, when less quantity available, reduce quantity and reset client-side stock level
This commit is contained in:
@@ -47,6 +47,14 @@ Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http, storage)->
|
||||
li.quantity = 0
|
||||
li.max_quantity = 0 if li.max_quantity?
|
||||
li.variant.count_on_hand = 0
|
||||
else
|
||||
if stockLevels[li.variant.id].quantity < li.quantity
|
||||
alert "Variant quantity reduced: #{li.variant.id}"
|
||||
li.quantity = stockLevels[li.variant.id].quantity
|
||||
if stockLevels[li.variant.id].max_quantity < li.max_quantity
|
||||
alert "Variant max_quantity reduced: #{li.variant.id}"
|
||||
li.max_quantity = stockLevels[li.variant.id].max_quantity
|
||||
li.variant.count_on_hand = stockLevels[li.variant.id].on_hand
|
||||
|
||||
popQueue: =>
|
||||
@update_enqueued = false
|
||||
|
||||
Reference in New Issue
Block a user