This topic has 8 replies, 3 voices, and was last updated 9 years, 1 months ago ago by Eva Kemp
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.
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 🙂 )
Hello,
Please refer to this article:
http://www.themelocation.com/how-to-add-quantity-field-with-each-product-on-shop-page-woocommerce/
Regards,
Eva Kemp.
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?
Hello,
Please try to use this code in Global Custom CSS.
.quantity{
left: 50%;
margin-left: -32px;
}
Regards,
Robert Hall.
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.
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.
Hi Eva, that’s worked really well. Thanks!
Hello,
You’re welcome.
Regards,
Eva Kemp.
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