• Resolved jakevoelcker

    (@jakevoelcker)


    For my workflow I often want to preserve woocommerce carts and sessions across multiple users.

    Is it possible to disable the new forget_woocommerce_session() functionality in the User Switching plugin?

    For now I have just commented out this line of code in the plugin, but is there a hook or a setting I could use which will not break on future updates?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    Thanks for the message.

    What’s your use case? Preserving carts and sessions doesn’t really work properly when switching between users.

    There isn’t a means of disabling this functionality but I could add something in.

    Thread Starter jakevoelcker

    (@jakevoelcker)

    Hi John,

    Thanks for the great plugin, it’s so useful. I also like that it’s really robust and professionally written with proper action hooks and support for filters.

    Our use case: we often start building an order whilst logged in as staff, or not logged in at all. If we then discover that the customer already has an account, it’s really useful to be able to switch without losing the cart contents.

    This worked really well until 1.5.0

    What parts of preserving carts and sessions doesn’t work well in your experience?

    Many thanks,
    Jake

    Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    I’ve moved this functionality into actions in User Switching 1.5.2 so it can be unhooked:

    
    add_action( 'init', function() {
        remove_action( 'switch_to_user', [ user_switching::get_instance(), 'forget_woocommerce_session' ] );
        remove_action( 'switch_back_user', [ user_switching::get_instance(), 'forget_woocommerce_session' ] );
    } );
    
    Thread Starter jakevoelcker

    (@jakevoelcker)

    Thanks very much John.

    Unfortunately it’s not working for me though. When I switch users, cart contents are lost.

    I upgraded to 1.5.2 and copied your code above into a code snippet that runs everywhere with priority 10, that should work shouldn’t it?

    (If I add items to the basket and then log in without using user switching, cart contents are preserved, so I know that is working fine).

    Plugin Author John Blackbourn

    (@johnbillion)

    WordPress Core Developer

    Hmm, can you try changing init in the sample code above to plugins_loaded?

    Thread Starter jakevoelcker

    (@jakevoelcker)

    Thanks for the suggestion, that works perfectly now ??

    Thanks for all your help John

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Disable forget_woocommerce_session()’ is closed to new replies.