Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Woocommerce add to cart url with quantity?

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.

like image 644
Rollor Avatar asked Mar 09 '15 16:03

Rollor


People also ask

How do I add multiple items to cart in WooCommerce?

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.

How do I create an Add to Cart URL?

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.


1 Answers

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>
like image 125
Jesús Carrera Avatar answered Oct 12 '22 23:10

Jesús Carrera