We want to automagically add a free product to the customers cart when they purchase a certain product(s).
Note: This code will likely need to be adapted to suit your theme, however it should be enough to discribe the concept.
Add the free product
Define the free product and which products can add it. We create some theme setting that allow us to pick the free product and a collection of products that can add it. e.g.
Collect the free product and hand it off to the JS. Get the current product, if we have one. Set up some conditions for adding. This is done inside the
<head>. See theme.liquid.
Capture the form submit and add the current and free products to the cart. See product.js
Remove the free product To do