Empty Cart once user logs out

Home Forums Legacy Support Support queries How-to & Troubleshooting Empty Cart once user logs out

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #366068
    CoreMarketingHub
    Spectator
    I have tried to apply this functionality -to empy the cart once user logs out- by adding some PHP code in my functions.php file, but no luck. e.g. 1) add_action( 'wp_logout', 'woocommerce_empty_cart' ); 2) function your_function() { if( function_exists('WC') ){ WC()->cart->empty_cart(); } } add_action('wp_logout', 'your_function'); Do you have something in mind for that? Is this related to BuddyPress log in flow?
    #366194
    Veronica
    Moderator
    hi you can search that out "clear cart on logout" i have searched that and found some links you can try them out: https://wordpress.org/support/topic/woocommerce-clear-cart-on-user-logout/ https://wordpress.stackexchange.com/questions/324961/woocommerce-cart-is-not-clear-after-logout/324963 https://njengah.com/woocommerce-clear-cart-on-logout/ https://stackoverflow.com/questions/32785328/woocommerce-clear-cart-on-user-logout
    #366226
    CoreMarketingHub
    Spectator
    yes, I have tried all these, but no luck
    #366307
    Veronica
    Moderator
    for that make sure you have enabled both the sync in vibebp>>settings
    #366326
    CoreMarketingHub
    Spectator
    Hi, these are my settings https://1drv.ms/u/s!AioWO8Qvek_2mMQ15uElWzq5PJJq6A?e=TJufLI
    #366327
    CoreMarketingHub
    Spectator
    these are my settings https://1drv.ms/u/s!AioWO8Qvek_2mMQ15uElWzq5PJJq6A?e=TJufLI
    #366398
    Veronica
    Moderator
    hi the delay in response is due to support holiday checking the code will provide here shortly
    #366406
    Veronica
    Moderator
    hi add this code in wplms-customizer.php `add_action( 'wp_logout', 'force_clear_woocommerce_cart' ); function force_clear_woocommerce_cart() { error_log("Clearing cart"); global $woocommerce; $woocommerce->cart->empty_cart(); }` this will clear the cart once the user is logged out from the WordPress area this is tested on local and working
    #366462
    CoreMarketingHub
    Spectator
    I have tried this in functions.php and it did not work. How can I access the wplms-customizer.php file ? Shall I go through the cpanel file manager, or I can find in the wp admin area ?
    #366475
    Veronica
    Moderator
    hi if you don't have the plugin then download it form here: https://wplms.io/support/wp-content/uploads/2015/08/wplms-customizer.zip and also you can edit the wplms-customizer.php from wp-admin>>plugins>>plugin editor>>select the wplms customizer plugin and then edit the file and update it
Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Empty Cart once user logs out’ is closed to new replies.