Let say someone decides to buy my product and click on the buy now option and reached my checkout page. But for some reason he/she didn't buy it. But after sometime he/she made his mind to purchase the product but when they click on buy know button the product price get doubles because the product is added a second time in the cart. As i am not giving access to the cart page to my visitor so they can't modify there cart.
Is there anyway with which I can prevent the same product adding a second time in cart. I don't want the min maximum plugin because it doesn't prevent from adding same product multiple time. It just shows a notification that the max amount is 1.
I just don't want the same product to be addded twice in the cart no matter what.
I tried this code:
add_filter( 'woocommerce_add_cart_item_data', 'woo_custom_add_to_cart' );
function woo_custom_add_to_cart( $cart_item_data ) {
global $woocommerce;
$woocommerce->cart->empty_cart();
// Do nothing with the data and return
return $cart_item_data;
}
But after adding it I am not able to add a second product into my cart. As I have added a order bump in my checkout page but when i tried to add it it replaced the main product.