Hi everyone,
I’m working on a custom Shopify Plus implementation and would love some guidance from the community.
Goal: Automatically add the “Get Y” product to the cart when the “Buy X” product (defined in an automatic Buy X Get Y discount) is added to the cart ( without using shopify app store)
What I’m Trying to Achieve : I want to retrieve the Buy X and Get Y product variant IDs — along with the required quantity — directly from the automatic discount configuration in Shopify.
Once I have those IDs, I’ll use them in my theme’s cart.js where I handle the logic of when a “Buy X” product is added to the cart, automatically add the matching “Get Y” product variant.
What I Need Help With
- How to fetch the Buy X and Get Y variant IDs and quantities from the automatic discount data ( using graphql query, is there a way to use shopify functions / custom app to retrieve the Buy X and Get Y)
Thanks in advance for any insights or shared experiences ![]()