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>
{packages_packages}
<option value="{sub:row_id}">
{sub:title}
</option>
{/packages_packages}
</select>
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"}
{packages_packages}
{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>
{input}
{if:else}
{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>
{/select}
<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>
</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>
</span>
</label>
{/if}
{/if}
{/exp:cartthrob:item_options}
{/packages_packages}
Here I'm showing all options in their own select lists and setting the initial quantity to 0.
<p>
<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>
</p>
{/exp:cartthrob:add_to_cart_form}
{/exp:channel:entries}
Yet, when I hit "Add to cart" it adds the first option of each select list with a quantity of one.