I am allowing non-logged-in customers to order to my website with the code below:
global $woocommerce;
if(empty($woocommerce->session->data)){
$woocommerce->session->set_customer_session_cookie(true);
}
I want to destroy the session after an order has been made because all non-logged-in customers share the same session cookie and this can flood the cart.
function wc_destroy_customer_session() {
global $woocommerce;
$woocommerce->session->destroy_session();
}
add_action('woocommerce_thankyou', 'wc_destroy_customer_session', 10, 1);
The code above still does not destroy the wp_woocommerce_session_random_hash
Do you know how to make the destroy_session
work? Thanks
Woocommerce Documentation:http://woocommerce.wp-a2z.org/oik_api/wc_session_handlerdestroy_session/