Skip to content

Instantly share code, notes, and snippets.

@greguly
Created December 6, 2016 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save greguly/08765cf325e4e91176279e67b4534718 to your computer and use it in GitHub Desktop.
Save greguly/08765cf325e4e91176279e67b4534718 to your computer and use it in GitHub Desktop.
Unsetting WooCommerce Session Variables
<?php
/**
* In answer to https://twitter.com/Kathy_Darling/status/805902856536674304
*
* Anyone know how to remove a @WooCommerce session variable once you've set it?
*
*/
// One can set the variable to null, like it is done with wc_notices:
WC()->session->set( 'wc_notices', null );
// Or really unset is as in
WC()->session->__unset( 'wc_notices' );
// source: https://github.com/woocommerce/woocommerce/blob/release/2.6/includes/abstracts/abstract-wc-session.php#L57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment