less than a minute read • Updated 20 minutes ago
Prevent child products from being removed
How to lock a child product in the cart so customers cannot remove or adjust it independently from its parent.
By default, customers can remove or adjust the quantity of any product in the cart, including child products. To prevent this, set quantity_min and quantity_max to 1 on the child product. This locks the quantity and removes the delete option for that item in the cart.
How to set it up
Add quantity_min and quantity_max to the child product in your link or form:
<form action="https://YOURSUBDOMAIN.foxycart.com/cart" method="post">
<input type="hidden" name="name" value="Parent product" />
<input type="hidden" name="price" value="19.99" />
<input type="hidden" name="code" value="741" />
<input type="hidden" name="2:name" value="Child product" />
<input type="hidden" name="2:price" value="0.00" />
<input type="hidden" name="2:parent_code" value="741" />
<input type="hidden" name="2:quantity_min" value="1" />
<input type="hidden" name="2:quantity_max" value="1" />
<input type="submit" value="Add to cart" />
</form>
Notes
Setting
quantity_min=1andquantity_max=1locks the quantity at exactly 1 and removes the ability to delete the child product independently.The child product will still be removed if the parent product is deleted from the cart.
quantity_minandquantity_maxcan be used independently — for example,quantity_min=1alone prevents removal but still allows the customer to increase quantity.