Forum
Variants as a dropdown
Hi
I'm having difficulty making my Shop Variants as a dropdown and added info from https://docs.grabaperch.com/templates/field-types/select/ and currently have;
<perch:variants>
<div class="variant">
<perch:variant id="productVariantDesc" type="text"/>
<perch:variant id="price" type="shop_currency_value" />
<perch:form id="add_to_cart" type="select" label="Select option" allowempty="false" required="true" options="<perch:variant id="productID" type="hidden" env-autofill="false" />" app="perch_shop" action="/shop/cart" class="add-to-cart-form">
<perch:input id="product" type="hidden" env-autofill="false" value="<perch:variant id="productID" type="hidden" env-autofill="false" />" />
<perch:input type="submit" value="Add to cart" class="btn btn-primary btn-sm"/>
</perch:form>
</div>
</perch:variants>
Any help would be greatly received.
Something like:
Thanks Drew
Its not quite loading the variants in the dropdown, its adding a dropdown to each variant listed... but its a good start I will keep tweaking...
Wayne
I've tried a range on the example you've given and no joy... I currently have;
Which is listing the options in a row, rather than a select/dropdown with an add to cart button. Where am I going wrong on this?
Not within
perch:variants
- this is a precompiled string, you don't need to iterate.Thanks. I've removed perch:variants and currently have;
Which isn't showing anything...
Hey Wayne,
I have tested what Drew's suggested and it works fine for me. So your issue isn't with:
Thanks
I must be doing something wrong. I've looked at the source and the options are there, but its not displaying... I will keep testing....
It's in the default templates.
Got it working. Here's my code for reference;