I'm trying to only allow items to be added to Cartthrob's cart based on a selection made. However, before I can do that, I need to solve why the cart is updating with items even though their amount is set to zero.

How can I tell cartthrob to either/or give me a non-selected option, or to ignore adding an item whose quantity is 0, or both?

My code is as follows:

{exp:channel:entries channel="store_packages"}
    <select name="packages" id="packages-select" class='width-70 margin-bottom'>
        <option value="">Please Select</option>
            <option value="{sub:row_id}">

I'm hoping to use the above to be able to hide/show package options based on this selection.

{exp:cartthrob:add_to_cart_form class='forms' entry_id="{entry_id}" no_tax="{no_tax}" no_shipping = "{no_shipping}" return="/store/view_cart"} 

        {exp:cartthrob:item_options row_id="{sub:row_id}" entry_id="{entry_id}"}
            {if dynamic}
                <label class="control-label" for="{option_field}">{option_label}</label>
                {if options_exist}
                    {select class='width-70 margin-bottom'}
                        <option {selected} value="{option_value}">{option_name} {if option_price_numeric != 0} +{option_price}{/if}</option>

                    <label class="input-groups" id="quantity-modiphier">
                        <span class="btn-append">
                             <span class="btn btn-black" id="less-quantity"><i class="icon icon-minus"></i></span>
                        <input type="text" id="product_quantity" name="quantity" value="0">
                        <span class="btn-append">
                             <span class="btn btn-black" id="more-quantity"><i class="icon icon-plus"></i></span>

Here I'm showing all options in their own select lists and setting the initial quantity to 0.

        <button type="submit" class="btn btn-green">Add to Cart</button>
        <a href="#" class="btn btn-disabled">Checkout</a>
        <a href="#" class="btn btn-disabled"><i class="icon icon-shopping-cart"></i>View Cart</a>



Yet, when I hit "Add to cart" it adds the first option of each select list with a quantity of one.

1 Answer 1


The answer to why cartthrob was adding items to the cart although the quantity was set to zero is that the cartthrob settings used the packages channel for pricing rather than the product options from the product channel. This is modified in cartthrob's products settings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.