To automatically add a free product to the cart, you can set up a Buy X Get Y offer in the BOGOS App. With this feature, when a customer clicks “Add to cart” for the main product, the free gift will be instantly added to the cart drawer without any manual action from the customer.
What you’re seeing in the example (where product Y is automatically added when product X is added to the cart) is typically done using a buy X get Y (BOGO) or bundle logic, not just a simple product ID inside the form.
The best and safest way to achieve this, especially with cart drawers and AJAX carts, is by using a dedicated bundle/BOGO app like Wizio Bundle – Buy X Get Y. Automatically add Product Y when Product X is added to the cart.
Suppose your goal is to add product Y automatically when product X is added to the cart and show it in the cart drawer. Use a Buy X Get Y / bundle solution instead of custom product-ID logic.