Created
October 26, 2015 07:00
-
-
Save octalmage/563b885ef8df1a017a23 to your computer and use it in GitHub Desktop.
Force clear WooCommerce cart for WordPress user.
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
<?php | |
add_action( 'init', 'force_clear_woocommerce_cart' ); | |
function force_clear_woocommerce_cart() | |
{ | |
$user_ID = get_current_user_id(); | |
if ($user_ID === 68364) | |
{ | |
error_log("Clearing cart"); | |
global $woocommerce; | |
$woocommerce->cart->empty_cart(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had to move the add_action below the function for this to work for me. Thank you : )