wc_empty_cart

Clears the cart session when called.

Description

wc_empty_cart(); 

Usage

  1. if ( !function_exists( 'wc_empty_cart' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-cart-functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wc_empty_cart(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-cart-functions.php  
  1. function wc_empty_cart() { 
  2. if ( ! isset( WC()->cart ) || '' === WC()->cart ) { 
  3. WC()->cart = new WC_Cart(); 
  4. WC()->cart->empty_cart( false );