[Plugin: WooCommerce] Hidden Inputs in Add to Cart Form
-
Hi all,
I’m currently trying to add my own custom product options to a product in WooCommerce. For reasons that would take a lot of explaining, the existing plugins for product variation won’t work, I need to do it custom.
I’ve added input fields to the add to cart form on the product page, like so:
<input type="hidden" name="some option" value="option choice">
I had hoped, perhaps naively, that it would really be that simple (it is in Shopify!). Unfortunately, not so.
So: how can I make these hidden input fields work? How can I make them add their custom information to the product when its added to the cart, and carry that information through the checkout process until its stored in the order information at the end?
If anyone is wondering, the <input> fields are being added via Javascript.
If you need, the add to cart form code – with the input fields – is below:
<form class="cart" method="post" enctype='multipart/form-data'> <div class="quantity"> <input type="number" step="1" min="1" max="" name="quantity" value="1" title="Qty" class="input-text qty text" size="4" pattern="[0-9]*" inputmode="numeric" /> </div> <input type="hidden" name="some option" value="option choice"> <input type="hidden" name="some option" value="option choice"> <input type="hidden" name="add-to-cart" value="8" /> <button type="submit" class="single_add_to_cart_button button alt">Add to cart</button> </form>
- The topic ‘[Plugin: WooCommerce] Hidden Inputs in Add to Cart Form’ is closed to new replies.