Add quantity button to the item list
-
Hi,
Congratulations on the great job.I used the code made available by WooCommerce Docs at this link:
https://docs.woocommerce.com/document/override-loop-template-and-show-quantities-next-to-add-to-cart-buttons/To display the quantity buttons next to the Add to Cart button for products.
This was the code used:
function quantity_inputs_for_woocommerce_loop_add_to_cart_link( $html, $product ) { if ( $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) { $html = '<form action="' . esc_url( $product->add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data">'; $html .= woocommerce_quantity_input( array(), $product, false ); $html .= '<button type="submit" class="button alt">' . esc_html( $product->add_to_cart_text() ) . '</button>'; $html .= '</form>'; } return $html; } add_filter( 'woocommerce_loop_add_to_cart_link', 'quantity_inputs_for_woocommerce_loop_add_to_cart_link', 10, 2 );Although, I found a possible bug in the code.
On the product page, when UpSell and Related Products are being displayed.
When changing the quantity in one, the others are also changed.
Note this error does not occur with CrossSell products on the Cart page.
Does anyone know what may be causing this?
Thanks.
The topic ‘Add quantity button to the item list’ is closed to new replies.