I have added code to only allow 1 item in the cart at one time. However, when a user adds any item to their cart, it does NOT direct them to the Cart page.
Here is the code that I am using:
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();
wc_add_notice( 'WARNING MESSAGE - You can only have 1 Item in your Cart. Previous Items have been removed.', 'error' );
return $cart_item_data;
}
So my goal is to keep this function and error message but take the user to the cart. I am sure there is something in this code that is preventing the user from going to the cart and staying on the product page.
Thanks in advance for your help!