Forum
Perch Shop: Buttons with amounts --> add to cart...
I've created a form for donations that creates buttons for the set donation amounts using the <perch:productvalues>
tags:
<div class="product clearfix">
<perch:form id="add_to_cart" app="perch_shop" action="/cart">
<perch:productopts><perch:productvalues> <button class="button button-rounded button-reveal button-large button-green"><i class="icon-gift"></i><span> <perch:productvalue id="valueTitle" /></span></button>
</perch:productvalues> </perch:productopts>
<perch:input id="product" type="hidden" env-autofill="false" value="<perch:shop id="productID" type="hidden" env-autofill="false" /> " />
<perch:input type="cms" />
</perch:form>
</div>
But I don't know how to get the product value to submit on the button press. Any help would be much appreciated!
Are you asking how to add a variant to the cart?
I guess, yes. Ideally from the button push from the
perch:productvalue
listing. The above template outputs:Are you following this example?
https://docs.grabaperch.com/addons/shop/examples/add-to-cart-options/
Yes, I think I'm doing that. I want the options to be button pushes to add the option amount to the cart. So I think it's on me to figure that out. May switch to a dropdown of options (like the example you linked) and then have the submit button...
Thank you!
so should this work? Would this be enough to get a product variant into the cart? Cant get it to add to cart.
here's the full code:
It correctly creates a series of forms to pass in product variant amounts, but nothing gets added to the cart.
here's a sample of the code perch is generating from the template above:
This was the solution for how to get buttons for the variants. This is useful for me for making donations of set amounts in the shop app.