Quantcast
Channel: WordPress.org Forums » [WooCommerce] Support
Viewing all articles
Browse latest Browse all 104029

Omar Fitzpatrick on "[Plugin: WooCommerce - excelling eCommerce] Adding Quantity to archive page add to cart"

$
0
0

One should avoid touching the plugin's code wherever possible and explore the simpler solutions using the hooks in WooCommerce. I had a similar problem and I solved it by doing the following:

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', 30); // replace it with the Add To Cart Button, complete with QTY field.. the same one that is used on the Single Product page.

woocommerce_show_messages(); // call this WooCommerce function where you want the "X item has been added to cart" message to appear.  Note that this will also override the location of other WooCommerce messages generated by this function.

This code may also affect other pages where the ajaxified Add To Cart button was called via the woocommerce_after_shop_loop_item action, but I assume having the QTY field can only be a benefit, really... :)


Viewing all articles
Browse latest Browse all 104029

Trending Articles