Forum

Thread tagged as: Shop

Is there a way to not show inventory in variant drop-down...

So:

<perch:input id="product" type="select" class="variants" options="<perch:shop id="_variant_opts" type="hidden" />" placeholder="Please choose" required="true" class="sm-form-control" />

brings the variants onto the template... But can you control whether or not the stock level is shown? If so, what template would that be?

Monty Lewis

Monty Lewis 2 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Not currently. The alternative is to template them directly: https://docs.grabaperch.com/addons/shop/products/template-tags/options/

I see, thank you.

So if I wanted to duplicate the standard dropdown, just without the inventory levels it would be something like this:

<perch:if exists="has_variants">     
    <perch:productopts>
        <perch:productvalues>
          <perch:before>
              <select id="form1_product" name="product" class="sm-form-control" placeholder="Please choose" required="required">
                  <option disabled="disabled" selected="selected" value="">Please choose</option>
          </perch:before>
                    <option value="<perch:productvalue id="valueID" />"><perch:productvalue id="valueTitle" /></option>
          <perch:after>
              </select>
          </perch:after>
        </perch:productvalues>
    </perch:productopts>
    <perch:input id="product" type="hidden" value="<perch:shop id="productID" type="hidden" />" />
     <perch:else />
           <perch:input id="product" type="hidden" env-autofill="false" value="<perch:shop id="productID" type="hidden" />" />
</perch:if>

The options display correctly for me but the add to cart button no longer adds the selected item to the cart...

Looking at source, with the default dropdown, my option values are 19, 22 and 25; but with the code above, the values are 5,6 and 7. So <perch:productvalue id="valueID" /> must be the incorrect tag. Also, would I just pick up the id of the select element from the default dropdown code as I did here?

Thanks for your help!

Drew McLellan

Drew McLellan 2638 points
Perch Support

Those aren't product IDs - they're option value IDs. You need to specify the field name as per the documentation and also provide the productID that the options relate to.

If you have multiple options I'm not sure that's easy to do in a single select field.

so I'm doing it wrong or you don't think it's doable? Either way, I guess it's beyond me.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Do you have multiple options or just one?

Just sizes in this case.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I think it's probably possible to do in that case. You could prototype it using the radio button example in the documentation.

what would be the perch tag that calls in the option id?

Drew McLellan

Drew McLellan 2638 points
Perch Support

There's an example here under "full control": https://docs.grabaperch.com/addons/shop/products/template-tags/options/