I can hard code an add to cart url, it works just fine.
<a href="' . get_home_url() . '/product/myproduct/?add-to-cart=101">Add to cart</a>
However, I'd like to know if I can add the quantity to this query string? Say, like:
<a href="' . get_home_url() . '/product/myproduct/?add-to-cart=101&quantity=2">Add to cart</a>
Is this even possible and I just don't know the right query string word for quantity? Thanks.
WooCommerce Product Table lets you add multi-select checkboxes alongside (or in place of) the Add to Cart buttons in the product table view. Customers will be able to tick the checkboxes next to the products they'd like to buy and select multiple products.
The easiest way to create an Add to Cart URL for a variable product is by going to the variable product page and choosing the options that you want to use in your URL. Then add the product to the cart and visit the cart page. In example, I have a T-Shirt for which the customer can choose the size and the color.
Yes, quantity
will work, and you can use any base url (home for example), then, by default it will redirect to your cart page.
<a href="' . get_home_url() . '?add-to-cart=101&quantity=2">Add to cart</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With