Support » Plugin: WooCommerce » add_to_cart shortcode quantity argument

  • Resolved alastairin


    I am using the add_to_cart shortcode within a page to output a button to add a product to the cart. I wish to add 2 of the product to the cart, so am using the argument quantity=”2″. However, only 1 is added to the cart. Example:

    [add_to_cart id="1234" quantity="2" show_price="FALSE" style=""]

    The button that is output contains link with query string: ?add-to-cart=1234.
    I was expecting the string to be: ?add-to-cart=1234&quantity=2.

    Am I misunderstanding what the shortcode quantity argument should do? Or is this not working as it should?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter alastairin


    I’m not sure what the cause was, but deleting Woocommerce files and reinstalling has fixed.

    Thread Starter alastairin


    The issue was caused by modifying function “template_loop_add_to_cart”, as here:

     * Hide loop read more buttons for out of stock items 
    if (!function_exists('woocommerce_template_loop_add_to_cart')) {
    	function woocommerce_template_loop_add_to_cart() {
    		global $product;
    		if ( ! $product->is_in_stock() || ! $product->is_purchasable() ) return;

    When this code is removed from the child theme’s functions.php the arguments in the shortcode are handled correctly. And when the code is updated to handle the shortcode arguments it works too.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.