How can i make add-to-cart button with custom quantity attribute?
I can add:
?add-to-cart=335,338,339&quantity=3,2,1
to my page link and it works well, but i want to make button with those attributes.
Default one:
<button type="submit" name="add-to-cart" value="332,333,338&quantity=3,2,1" class="single_add_to_cart_button button alt">Add to cart</button>
adds products, but always 1, quantity field don't work.
I know i can pass those attributes by <a href="...">
but i want to do it proper way.
You need to use the attribute data-quantity
in ur <a>
tag.
Example - add 3 units from Product with ID 332: <button type="submit" name="add-to-cart" value="332" class="single_add_to_cart_button" data-quantity="3">Add to cart</button>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.