WooCommerce Check if item is already in cart, if yes, then redirect user to checkout without adding product. Learn how to add the feature to your ecommerce website.
Are you selling digital products and you are looking for a way to stop duplicate sale of the same product? In this tutorial you will learn how to maneuver on this. We are going to add the feature with:
User clicks add to cart button.
Function checks if the item is already in the cart.
If yes: Redirect user to checkout page without adding the product to cart (so the quantity doesn’t change, it stays at 1).
If no: Redirect to checkout and add product to cart (quantity goes from 0 to 1).
Conclusion In summary
In conclusion, we added a feature that:
User clicks add to cart button.
Function checks if the item is already in the cart.
If yes: Redirect user to checkout page without adding the product to cart (so the quantity doesn’t change, it stays at 1).
If no: Redirect to checkout and add product to cart (quantity goes from 0 to 1).