WooCommerce: Change Product Quantity @ Checkout Page

We covered a lot of WooCommerce Checkout customization in the past – it’s evident that the Checkout is the most important page of any WooCommerce website!

Today we’ll code a nice UX add-on: how do we show product quantity inputs beside each product in the Checkout order table? This is great if people need to adjust their quantities on the checkout before completing their order; also, it’s helpful when you have no Cart page and want to send people straight to Checkout and skip yet another click.

In this post, we’ll see how to add a quantity input beside each product on the Checkout page, and then we’ll code a “listener” to make sure we actually refresh the Checkout and update totals after a quantity change. Enjoy!

You can clearly see that there is a new quantity input inside the “Order Review” section of the WooCommerce Checkout page. On change, the Checkout will refresh and update totals.

PHP Snippet: Display Product Quantity Selectors @ WooCommerce Checkout

Note: you may need to adjust alignment between product name and the new quantity input with custom CSS.

 * @snippet       Item Quantity Inputs @ WooCommerce Checkout
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 7
 * @donate $9     https://businessbloomer.com/bloomer-armada/

// ----------------------------
// Add Quantity Input Beside Product Name
add_filter( 'woocommerce_checkout_cart_item_quantity', 'bbloomer_checkout_item_quantity_input', 9999, 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,
			'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' );

function bbloomer_update_item_quantity_checkout( $post_data ) {
	parse_str( $post_data, $post_data_array );
	$updated_qty = false;
	foreach ( $post_data_array as $key => $value ) {	
		if ( substr( $key, 0, 20 ) === 'shipping_method_qty_' ) {			
			$id = substr( $key, 20 );   
			WC()->cart->set_quantity( $post_data_array['product_key_' . $id], $post_data_array[$key], false );
			$updated_qty = true;
	if ( $updated_qty ) WC()->cart->calculate_totals();

Mini-Plugin: Business Bloomer WooCommerce Change Product Quantity On The Checkout Page

You don’t feel confident with coding? You need customers to update their cart on the Checkout Page? You don’t want to purchase yet another bloated, expensive plugin? Great!

Business Bloomer WooCommerce Change Product Quantity On The Checkout Page is a mini WooCommerce plugin, without the usual hassles. One feature. Lifetime license. No annoying subscriptions. 1 plugin file. A few lines of code. No banners. No up-sells. No WP notifications. Use it on as many websites as you like. Lifetime support. 1-page documentation. No settings dashboard.

Quick demo:

As you can see the plugin is pretty straight forward. Install it. See the magic happen. Simple!

Was this article helpful?

Where to add custom code?

You should place PHP snippets at the bottom of your child theme functions.php file and CSS at the bottom of its style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my guide "Should I Add Custom Code Via WP Editor, FTP or Code Snippets?" and my video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything went as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting.

If you think this code saved you time & money, feel free to join 17,000+ WooCommerce Weekly subscribers for blog post updates and 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance!

Need Help with WooCommerce?

Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.

16 thoughts on “WooCommerce: Change Product Quantity @ Checkout Page

  1. is it possible to change the quantity field to + – buttons?

    1. Hi Abu, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  2. Hi thanks for the snippet. Have added this and see the input selector on the checkout but when I increase/decrease it refreshes over ajax but reverts back. Not updating quantity. Tried popping it into troubleshoot mode and disabling all the plugins etc… assuming a conflict but cant seem to identify the issue. No errors in the console either.

    Does this still work with the latest version of Woo? Any thoughts on a fix?

    1. Weird. Do you get any JS errors?

  3. Is it possible to do something like that to change or assign values for attributes other than price in WooCommerce Checkout?

    I’m trying to assign a cart item attribute and update product price on checkout, but haven’t found the way…

    1. Hi Oswaldo, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  4. Nice snippet, but i have some problem, food ordering site, when customer order same product but different addons, only last frome same products on cart work + – , when all products different , works on all. Some idea for fix ? Thanks


    1. Thanks Bosko. In such case I believe a custom integration needs to be developed in order to make it work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

      1. hello! great snippet, it works for me, but the display of the price in the product line is not enough, as it is displayed without the snippet. It is especially convenient for the client to see the price too when there are several items in the checkout.

        Can you tell me what code to add so that the product amount is also displayed?

        1. Hi Volodymyr, price is meant to update when you update the quantity (checkout does refresh). Did you change anything in my snippet?

          1. It works perfectly but it doesn’t show price in line. Only subtotal. Can you edit snippet please?

            1. Not sure I follow. Can you send me a screenshot of the checkout page without and with the snippet active, and show me the inline price?

              1. Hi Rodolfo, thanks for another great snippet!
                I think maybe what Thom is referring to in his comment above is that the Subtotal field seems to be populated by the quantity selector and would like the subtotal line for each product to be displayed as well.
                Also, is there a way to display the -+ (subtract, add) signs next to the quantity field, I can see them momentarily when I change the quantity but then they vanish, might be easier for customers to see that the quantity field is editable.

                Keep up the good work!

                1. OMG I totally did not see the bug until today. Snippet fixed!

                  1. Thank you for this code. I saw a bug. The + – (plus and minus) signs next to the quantity field is vanish whenever I change the quantity on checkout.

                    1. I can’t replicate this bug. What theme are you on?

Questions? Feedback? Support? Leave your Comment Now!

If you are writing code, please wrap it between shortcodes: [php]code_here[/php]. Failure to complying with this (as well as going off topic, not writing in English, etc.) will result in comment deletion. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining BloomerArmada to get blog comment reply priority, ask me 1-to-1 WooCommerce questions and enjoy many more perks. Thank you :)

Your email address will not be published. Required fields are marked *