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

Related reading:

Shiv Kumawat

Executive Director & CEO

Shiv Kumawat is the CEO of Eoxys IT Solution LLP, the Jaipur-based IT company he has led since 2009. An AI & IT Solutions Consultant with 16+ years of experience, he works with startups and enterprises to turn ideas into market-ready SaaS platforms, mobile apps and AI-driven solutions. His team has delivered 700+ projects across SaaS, mobile and web apps, automation and AI. He previously served as Chief Technology Officer for a US company.

Latest Posts

AI agent approach illustration: an AI agent on a platform connected to tools, email, browser and a completed task

Hire an AI Automation Engineer: Skills, Tools and Cost in 2026

If your team spends hours copying data between tools, sorting emails or chasing invoices, you may not need a full…

Shafeeq Khan
November 8, 2026
AI visibility audit illustration: a rising search visibility chart, an eye symbol and ranked podium blocks

How to Write Content AI Search Will Cite: Google vs Microsoft

Most advice on writing content for AI search comes from tool vendors and agencies. Google and Microsoft have now published…

Shafeeq Khan
November 7, 2026
RAG vs fine-tuning illustration: an AI model drawing on a knowledge base of documents on an isometric navy platform

RAG vs Fine-Tuning in 2026: Which One Your AI App Needs

When an AI app gives wrong or generic answers, the usual question is RAG vs fine-tuning: should you connect the…

Shafeeq Khan
November 6, 2026
,

Leave a Reply

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