WPIntell

Source evidence

Not working

Add Quantity Field to Woocommerce archives, shop & category · support · 2016-08-02T17:44:00+00:00

complaintsentiment
mediumseverity
0.86relevance
2replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

6 / 34 rows with source links

17.6% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

28 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
benamo6 unresolved
It simply adds only 1 product despite the amount chosen. Help please https://wordpress.org/plugins/add-quantity-to-archive-category-page/ Was this finally working for you? Same issue here After update woocomerce appear this problem. Replace in plugin code “post-type-archive-product” to “type-product”. Another way. Delete plugin. Insert this code to function.php (file is located in your theme folder) /** * Add quantity field on the archive page. */ function custom_quantity_field_archive() { $product = wc_get_product( get_the_ID() ); if ( ! $product->is_sold_individually() && ‘variable’ != $product->product_type && $product->is_purchasable() ) { woocommerce_quantity_input( array( ‘min_value’ => 1, ‘max_value’ => $product->backorders_allowed() ? ” : $product->get_stock_quantity() ) ); } } add_action( ‘woocommerce_after_shop_loop_item’, ‘custom_quantity_field_archive’, 9, 9 ); /** * Add requires JavaScript. */ function custom_add_to_cart_quantity_handler() { wc_enqueue_js( ‘ jQuery( “.type-product” ).on( “click”, “.quantity input”, function() { return false; }); jQuery( “.type-product” ).on( “change input”, “.quantity .qty”, function() { var add_to_cart_button = jQuery( this ).parents( “.product” ).find( “.add_to_cart_button” ); // For AJAX add-to-cart actions add_to_cart_button.data( “quantity”, jQuery( this ).val() ); // For non-AJAX add-to-cart actions add_to_cart_button.attr( “href”, “?add-to-cart=” + add_to_cart_button.attr( “data-product_id” ) + “&quantity=” + jQuery( this ).val() ); }); ‘ ); } add_action( ‘init’, ‘custom_add_to_cart_quantity_handler’ );

Comments

2 shown
zetaequis 2017-02-20T21:38:00+00:00

Was this finally working for you? Same issue here

orenburger 2017-02-25T17:12:00+00:00

After update woocomerce appear this problem. Replace in plugin code “post-type-archive-product” to “type-product”. Another way. Delete plugin. Insert this code to function.php (file is located in your theme folder) /** * Add quantity field on the archive page. */ function custom_quantity_field_archive() { $product = wc_get_product( get_the_ID() ); if ( ! $product->is_sold_individually() && ‘variable’ != $product->product_type && $product->is_purchasable() ) { woocommerce_quantity_input( array( ‘min_value’ => 1, ‘max_value’ => $product->backorders_allowed() ? ” : $product->get_stock_quantity() ) ); } } add_action( ‘woocommerce_after_shop_loop_item’, ‘custom_quantity_field_archive’, 9, 9 ); /** * Add requires JavaScript. */ function custom_add_to_cart_quantity_handler() { wc_enqueue_js( ‘ jQuery( “.type-product” ).on( “click”, “.quantity input”, function() { return false; }); jQuery( “.type-product” ).on( “change input”, “.quantity .qty”, function() { var add_to_cart_button = jQuery( this ).parents( “.product” ).find( “.add_to_cart_button” ); // For AJAX add-to-cart actions add_to_cart_button.data( “quantity”, jQuery( this ).val() ); // For non-AJAX add-to-cart actions add_to_cart_button.attr( “href”, “?add-to-cart=” + add_to_cart_button.attr( “data-product_id” ) + “&quantity=” + jQuery( this ).val() ); }); ‘ ); } add_action( ‘init’, ‘custom_add_to_cart_quantity_handler’ );