Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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