Display Product Quantity Selectors @ WooCommerce Checkout

PHOTO EMBED

Mon Jan 15 2024 12:17:40 GMT+0000 (Coordinated Universal Time)

Saved by @brozool

add_filter( 'woocommerce_checkout_cart_item_quantity', 'bbloomer_checkout_item_quantity_input', 999,  );

  
3
function bbloomer_checkout_item_quantity_input( $product_quantity, $cart_item, $cart_item_key ) {

   $product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key );

   $product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key );

   if ( ! $product->is_sold_individually() ) {

      $product_quantity = woocommerce_quantity_input( array(

         'input_name'  => 'shipping_method_qty_' . $product_id,
9
         'input_value' => $cart_item['quantity'],

         'max_value'   => $product->get_max_purchase_quantity(),

         'min_value'   => '0',

      ), $product, false );

      $product_quantity .= '<input type="hidden" name="product_key_' . $product_id . '" value="' . $cart_item_key . '">';

   }

   return $product_quantity;

}

 

// ----------------------------

// Detect Quantity Change and Recalculate Totals

 

add_action( 'woocommerce_checkout_update_order_review', 'bbloomer_update_item_quantity_checkout' );
content_copyCOPY