Warning: This function has been deprecated.

wc_load_persistent_cart( string $user_login, WP_User $user )

Load the persistent cart.


Description Description


Parameters Parameters

$user_login

(Required) User login.

$user

(Required) User data.


Top ↑

Source Source

File: includes/wc-cart-functions.php

function wc_load_persistent_cart( $user_login, $user ) {
	if ( ! $user || ! apply_filters( 'woocommerce_persistent_cart_enabled', true ) ) {
		return;
	}

	$saved_cart = get_user_meta( $user->ID, '_woocommerce_persistent_cart_' . get_current_blog_id(), true );

	if ( ! $saved_cart ) {
		return;
	}

	$cart = WC()->session->cart;

	if ( empty( $cart ) || ! is_array( $cart ) || 0 === count( $cart ) ) {
		WC()->session->cart = $saved_cart['cart'];
	}
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.3 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.