function vaciar_carrito_al_salir() {
    if( function_exists('WC') ){
        WC()->cart->empty_cart();
    }
}
add_action('wp_logout', 'vaciar_carrito_al_salir');