Created
February 9, 2024 11:22
-
-
Save elias1435/7940820be66a7bc2ea463c6ae387cc83 to your computer and use it in GitHub Desktop.
WooCommerce: Only Allow 1 Product in the Cart. Place this code in functions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'woocommerce_add_to_cart_validation', 'product_only_one_in_cart', 9999 ); | |
function product_only_one_in_cart( $passed ) { | |
wc_empty_cart(); | |
return $passed; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment