wc_load_persistent_cart

Load the persistent cart.

Description

wc_load_persistent_cart( (string) $user_login, (WP_User) $user ); 

Parameters (2)

0. $user_login (string)
The user login.
1. $user (WP_User)
The user.

Usage

  1. if ( !function_exists( 'wc_load_persistent_cart' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-cart-functions.php'; 
  3.  
  4. // The user login. 
  5. $user_login = ''; 
  6.  
  7. // The user. 
  8. $user = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wc_load_persistent_cart($user_login, $user); 
  12.  

Defined (1)

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

/includes/wc-cart-functions.php  
  1. function wc_load_persistent_cart( $user_login, $user ) { 
  2. if ( ! $user || ! ( $saved_cart = get_user_meta( $user->ID, '_woocommerce_persistent_cart', true ) ) ) { 
  3. return; 
  4.  
  5. if ( empty( WC()->session->cart ) || ! is_array( WC()->session->cart ) || 0 === sizeof( WC()->session->cart ) ) { 
  6. WC()->session->cart = $saved_cart['cart'];