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

Isometric illustration of an old AI model chip being swapped for a new one in a server that powers web and mobile apps, for a GPT-4o API migration guide

GPT-4o API Shutdown: Migrate Your App Before 14 January 2027

If your chatbot, document pipeline or internal tool still calls GPT-4o or GPT-4.1, it has a deadline. On 14 October…

Shafeeq Khan
October 19, 2026
Isometric illustration of an online store connected to an AI chatbot that handles order tracking, product search, returns and hand-off to a human support agent

AI Chatbot for E-commerce Stores: Use Cases, Stack and Cost

Most store chats are the same few questions: where is my order, will this fit, can I return it. With…

Shafeeq Khan
October 18, 2026
Isometric illustration of an AI vendor vetting checklist on a clipboard, a magnifying glass inspecting server racks, and shield, padlock, contract and key tiles on a deep navy background with teal and orange accents

How to Choose an AI Development Company: A Vetting Checklist

In the second week of October 2026, two regulators sent the same signal. The UK ICO reported on 8 October…

Shafeeq Khan
October 17, 2026
,

Leave a Reply

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