Conflicts when 2 auto-add-to-cart branches add the same product
complete
Tobe Osakwe
Auto add to cart: When multiple logic branches potentially add the same item to the cart, an issue can arise:
- If one branch's logic had previously passed, but no longer passes after an update to the cart, the shared item may not receive a discount anymore
This only seems to happen when both branches would add the same quantity of an item.
Most likely, this is due to the fact that this feature relies on 2 line item properties:
- Node ID
- Discount ID
There is probably a check missing somewhere that would have allowed the feature to properly distinguish between line items added by one node vs another.
Tobe Osakwe
complete
This was a challenging bug to diagnose.
We found 2 main issues:
- In Shopify, cart line IDs typically match the ID of the product variant in question, rather than being unique. This presents a challenge when multiple branches are trying to add/remove the same item. To work around this, we now remove items before adding new ones.
- We had a bug in our logic for calculating the new quantity of items before removing them.
Tobe Osakwe
in progress
Tobe Osakwe
planned