WooCommerce : Add same product to cart twice instead of changing quantity in Cart Page.

Code

How to add the same product twice to cart instead of changing quantity in WooCommerce

In normal case when we increase quantity of product in WooCommerce cart it simply increase quantity of same product that’s one product with incremented quantity.
But In some of cases, We like to have product in WooCommerce added in the cart as separate items and not as the same item with the changed quantity.
Basically we need to display separate cart items for product quantity > 1.
We can do that with pasting the code To the functions.php of theme.

This Is Done Basically In Two Steps:

 

Step 1: Split product quantities into multiple cart items.

 

In This Hooks Basically, when we are adding a new product to cart ,we have added a unique key to each cart item meta. that’s why the same product become distinct product each time.

For Adding unique meta key we will use ‘woocommerce_add_cart_item_data’ filter.


		function AddNewProductInsteadChangeQuantity( $cart_item_data, $product_id ) {
		  $distinctive_cart_item_key = md5( microtime() . rand() );
		  $cart_item_data['distinctive_key'] = $distinctive_cart_item_key;
		  return $cart_item_data;
		}
		add_filter('woocommerce_add_cart_item_data','AddNewProductInsteadChangeQuantity',11,2);
	

 

Step 2: Force add to cart quantity to 1 and disable +- quantity input .Product can still be added multiple times to cart

 


add_filter('woocommerce_is_sold_individually','__return_true' );
	
null

Shiv kumawat

Executive Director & CEO

"Shiv kumawat is the Executive Director and CEO of Eoxys It Solution LLP and the strategic mind behind the company"s growth. His expertise in operational efficiency and team leadership empowers his colleagues to excel and innovate.”

Latest Posts

Conversational AI in ECommerce: The Next Era of Online Shopping in 2025

  Conversational AI in ECommerce: The Next Era of Online Shopping in 2025 Welcome to the AIFirst Online Storefront By…

Shafeeq Khan
November 28, 2025

AI-Driven Learning Management Systems: Unlocking the Future of Digital Training in 2025

  AI-Driven Learning Management Systems:Unlocking the Future of Digital Training in 2025 Digital Learning Transformed by Artificial Intelligence The world…

Shafeeq Khan
November 5, 2025

Smarter Learning for a Smarter Era: How AI Is Transforming Learning Management Systems (LMS) in 2025

  Smarter Learning for a Smarter Era: How AI IsTransforming Learning Management Systems(LMS) in 2025 From Static Systems to Intelligent…

Shafeeq Khan
October 3, 2025
, ,

Leave a Reply

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