Enable option to choose quantity of products to add to cart from products page

This topic has 8 replies, 3 voices, and was last updated 9 years, 1 months ago ago by Eva Kemp

  • Avatar: JonathanWhite
    JonathanWhite
    Participant
    October 20, 2015 at 13:39

    How to I enable a form that allows the shopper to select the quantity of products to add to the cart. At the moment there is only an ‘Add to Cart’ button that allows the shopper to add one at a time.

    I’ve already entered some code into the functions.php file so the default value is 6 items but this doesn’t seem to work for the ‘Add to Cart’ button.

    See below for a screen shot and some (badly) drawn forms that I want to show.

    choose quantity of products to add to cart

    This screenshot shows a representation after using the Woocommerce [products] shortcode but there are other parts of the shop that only show ‘Add to Cart’ and the quantity cannot be chosen.

    All help much appreciate! (As always 🙂 )

    Please, contact administrator
    for this information.
    7 Answers
    Avatar: Eva
    Eva Kemp
    Support staff
    October 20, 2015 at 15:48
    Avatar: JonathanWhite
    JonathanWhite
    Participant
    October 22, 2015 at 09:42

    Hi Eva,

    I tried using the code from the link you provided and it the result was nothing being displayed on that page at all. I also tried the code at http://www.themelocation.com/how-to-add-quantity-field-for-products-on-archive-product-page-in-woocommerce/ but nothing happened at all.

    Using the heading of the page your recommended to search Google I found some Woothemes code that works. For anyone else wanting to replicate this functionality the page is https://docs.woothemes.com/document/override-loop-template-and-show-quantities-next-to-add-to-cart-buttons/.

    The issue I have now is through formatting. I want to have the box where the user puts their quantity directly above the ‘Add to cart’ button, and aligned centre. Currently it sits far to the left and may not be clear which product you are changing the quantity for.

    Is there something I can do to affect the layout here?

    Avatar: Robert Hall
    Robert Hall
    Support staff
    October 22, 2015 at 10:12

    Hello,

    Please try to use this code in Global Custom CSS.

    .quantity{
        left: 50%;
        margin-left: -32px;
    }

    Regards,
    Robert Hall.

    Avatar: JonathanWhite
    JonathanWhite
    Participant
    October 22, 2015 at 10:29

    Hi Robert,

    I’ve tried that code and had an issue because the quantity box and the button are on the same line, so the quantity box overlaid the button.

    The form that’s used to show the input box and button is:

    
    <form action="<?php echo esc_url( $product->add_to_cart_url() ); ?>" class="cart" method="post" enctype='multipart/form-data'>
    		
    			 <?php woocommerce_quantity_input(); ?>
    		
    			 <button type="submit" class="button alt"><?php echo $label; ?></button>
    		
    </form>

    I’ll include the site login details below if that can help too.

    Please, contact administrator
    for this information.
    Avatar: Eva
    Eva Kemp
    Support staff
    October 22, 2015 at 10:41

    Hello,

    I’ve added the code into CSS block of Visual Composer editor in your products page:
    http://storage1.static.itmages.com/i/15/1022/h_1445506833_7776260_e3fe5b8005.png

    Please check the page now.

    Regards,
    Eva Kemp.

    Avatar: JonathanWhite
    JonathanWhite
    Participant
    October 22, 2015 at 10:43

    Hi Eva, that’s worked really well. Thanks!

    Avatar: Eva
    Eva Kemp
    Support staff
    October 22, 2015 at 10:46

    Hello,

    You’re welcome.

    Regards,
    Eva Kemp.

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

The issue related to '‘Enable option to choose quantity of products to add to cart from products page’' has been successfully resolved, and the topic is now closed for further responses

8theme customization service

Helpful Topics

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