Woocommerce Quantity on shop page - by dflomin

This topic has 5 replies, 2 voices, and was last updated 9 years ago ago by Eva Kemp

  • Avatar: dflomin
    dflomin
    Participant
    April 2, 2015 at 18:36

    Hi,

    I’m trying to add quantity to the general shop page for each product. I’ve added the below to my functions.php file:

    remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart'); 
    add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_single_add_to_cart', 30);

    This does partially work – it got the quantity field to appear next to every product. However, actually adding the product is really buggy. It’ll add the quantity of a different product seemingly at random, e.g. 3 product1’s added to cart by the user, then when attempting to add 6 product2s to cart it adds 3 instead. The next add to cart click on product2 will then add 6, then back to 3. Very odd. Is there a way to implement this easily on the Royal theme? I know there are some changes I can do to the add-to-cart.php file in woocommerce/loop and have tried that, but it didn’t seem to work out too well at all.

    Any assistance is greatly appreciated!

    4 Answers
    Avatar: dflomin
    dflomin
    Participant
    April 2, 2015 at 18:44

    Some further testing revealed that the functions I pasted above are actually just adding product1 over and over, regardless of which add to cart btn is clicked, so obviously this solution isn’t going to work out.

    Avatar: Eva
    Eva Kemp
    Support staff
    April 2, 2015 at 18:56

    Hello,

    Sorry, but Shop page is configured by Woocommerce and you should contact their support for the solution.

    Please take our apologies for inconveniences.
    Regards,
    Eva Kemp.

    Avatar: dflomin
    dflomin
    Participant
    April 2, 2015 at 19:01

    Hi Eva,

    Thanks for the response! This functionality that I mentioned works normally on a regular Woocommerce installation, but Royal’s ajax submission doesn’t seem to play nicely with what I’m doing here, which is really what I’m trying to solve – keep the quantity field on the Shop page and have it tie in with the ajax submission.

    If this is outside the scope of your support then oh well I suppose – for anyone in the future looking at this trying for the same thing, I was able to copy paste the code from here
    https://claudiosmweb.com/snippets/woocommerce-loop-de-produtos-com-quantidade/
    into the appropriate file, and that disables the theme’s ajax submit but works normally with page refreshing.

    Avatar: Eva
    Eva Kemp
    Support staff
    April 2, 2015 at 19:35

    Hello,

    Sorry, but in this case you have to disable “Ajax “Add to Cart”” in Theme Options > Single Product Page.

    Thank you.
    Regards,
    Eva Kemp.

  • Viewing 5 results - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.