WordPress.org

Support

Support » Plugins and Hacks » WooCommerce » Showing quantity with add_to_cart shortcode

Showing quantity with add_to_cart shortcode

  • mrarrow

    @mrarrow

    So when I use the shortcode [add_to_cart id="213"], it shows a nice button to add the product to the shopping cart, but doesn’t display a quantity field. Also, if you view the shopping cart, you can’t edit the quantity for any items added via the add_to_cart shortcode. So it appears there’s no way of setting the quantity of that product which you wish to purchase.

    It works fine if you use the [product_page id="213"] shortcode for instance, but I’d have thought for consistency (and in my case usability), the ability to edit the quantity field should always be available.

    Anyone come across any fixes for this weirdness?

    http://wordpress.org/extend/plugins/woocommerce/

Viewing 13 replies - 1 through 13 (of 13 total)
  • Same issue here, did u find a solution?

    Nope, nada. So in the end, for consistency I just made sure all add to basket-type buttons showed no quantity options at all. Quantities are then changed on the Cart page.

    Ya, I’m finding no support for this module from WooCommerce or here. Moving onto Cart66

    Its very bad for usability reasons we need qty in the shortcode.
    It must be an option in the shortcode!!!

    I am also looking for a solution to this – there MUST be an answer to this

    I found this solution:
    Override loop template and show quantities next to add to cart buttons.

    It worked for simple products but not for variable products – the variables still show up without quantity options.
    Note that I pasted the code into add-to-cart.php replacing all the existing code. I backed up the original first!

    I found add-tocart.php in plugins/woocommerce/templates/loops/

    After doing the above I was able to reinsert the short code for add to cart… and the result was that quantities showed next to theadd-to-cart button!

    Hi Ron,

    I just tried your solution but it seems like the add to cart button doesn’t appear still. Did you do any extra steps to make it appear or it just did automatically? Hope you could help me out. Thanks!

    Mike

    After editing the add-to-cart.php I then inserted the woo short code for: Product price/basket button in a post, page or product. That is all.

    The other thing I did since then was save the edited php file in my theme folder: themefolder/woocommerce/loop/
    this will overide the original add-to-cart.php file which can remain unedited om the woocommerce plugins folder.

    Hope that helps

    Hi Ron,

    ahh! That’s what I was missing. I didn’t copy the file to the themefolder. I just did that and whala! Quantity was there. Thanks a lot for the help!

    Regards,

    Mike

    I did something similar by adding the following lines of code to the functions.php file in my theme (see below).
    I’ve noticed two problems, one is that the code adds the quantity to simple products but exposes all of the variations on variable products which makes the page looks really busy and unorganized. The second issue is that after adding a product the page has to reload itself.
    I’ll try your solution, hopefully I can follow it.
    =================
    remove_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’); // remove that ajaxified Add To Cart button that automatically adds 1 item to the cart.
    add_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_single_add_to_cart’, 1); // replace it with the Add To Cart Button, complete with QTY field.. the same one that is used on the Single Product page.
    ==========

    Hi,
    I tried your solution Ron but unfortunately I have a similar problem to the other solution I tried. Simple products are displayed correctly for the most part (a little CSS is required) but on variable products, all the associated variations for each product are shown which makes the category page very messy and unorganized.

    Did you have that problem and if so how did you solve this issue?

    Ron Troyer

    @ronrontroyercom

    Hi ouverz,
    No I didn’t have the problem of all the product variations showing. Sorry I can’t help you.

    Ron Troyer

    @ronrontroyercom

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Showing quantity with add_to_cart shortcode’ is closed to new replies.
Skip to toolbar