Automatically add a Product in the CART if condition is met

Topic summary

A developer seeks help implementing automatic cart functionality in Shopify. The requirement: When a “Leather Bag” with specific variant options (Black, Medium) is added to cart, automatically add a “Soft Winter Jacket” at $0.01. If the Leather Bag is removed, the jacket should also be removed automatically.

Current status: The user references Shopify’s “Add to Cart API” documentation and has attached screenshots showing:

  • Console output/errors
  • Documentation they’re attempting to follow

The post appears corrupted with reversed/garbled text in portions, making some technical details unclear. No solutions or responses have been provided yet. This remains an open question awaiting community guidance on implementing conditional cart additions using Shopify’s API.

Summarized with AI on November 25. AI used: claude-sonnet-4-5-20250929.

Can anyone Help me with this i want to add a PRODUCT AUTOMATICALLY in the CART if the conditions is met this is the Condition.

"

When the “Leather Bag” -with variant options “Black” & “Medium “ is added to the cart. automatically add the “Soft Winter Jacket” product to the cart for an additional price of 0.01$

  • If “Leather Bag” is removed from the cart make sure “soft winter Jacket” is also removed. "

and i attach what i see in the SHOPIFY DOCUMENTATION the ADD TO CART API i copy that in the DOCUMENTATION this image in the bottom

and in my console this one