WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
Showing quantity with add_to_cart shortcode (14 posts)

  1. mrarrow
    Member
    Posted 1 year ago #

    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/

  2. jebernier
    Member
    Posted 1 year ago #

    Same issue here, did u find a solution?

  3. mrarrow
    Member
    Posted 1 year ago #

    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.

  4. jebernier
    Member
    Posted 1 year ago #

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

  5. toto
    Member
    Posted 1 year ago #

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

  6. Ron Troyer
    Member
    Posted 1 year ago #

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

  7. Ron Troyer
    Member
    Posted 1 year ago #

    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!

  8. MikeDLV
    Member
    Posted 10 months ago #

    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

  9. Ron Troyer
    Member
    Posted 10 months ago #

    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

  10. MikeDLV
    Member
    Posted 10 months ago #

    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

  11. ouverz
    Member
    Posted 9 months ago #

    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.
    ==========

  12. ouverz
    Member
    Posted 9 months ago #

    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?

  13. Ron Troyer
    Member
    Posted 9 months ago #

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

  14. Ron Troyer
    Member
    Posted 9 months ago #


Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic