Input quantity
#567
-
How do I set input quantity to the products loop in shop loop and in the single product same as in the cart page ? Thanks |
Beta Was this translation helpful? Give feedback.
Answered by
crftwrk
Sep 11, 2023
Replies: 2 comments 1 reply
-
/**
* Show quantities next to add to cart buttons in loop
*/
add_filter( 'woocommerce_loop_add_to_cart_link', 'quantity_inputs_for_woocommerce_loop_add_to_cart_link', 10, 2 );
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 = wc_get_template_html( 'single-product/add-to-cart/simple.php' );
}
return $html;
} You need of course some additional CSS to fix the layout. Solved? |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
RobertCrx
-
Yes , but I would need to edit , because I want event to trigger on + or - or even input change , not on adding to cart , also I need to calculate and show the x amount of quantity before price when he change quantity |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
functions.php
:You need of course some additional CSS to fix the layout.
Solved?