Append blog ID on persistent cart user meta

This commit is contained in:
Mike Jolley 2017-06-08 13:47:23 +01:00
parent 6b4fce475a
commit 6eacecfeb6
3 changed files with 5 additions and 5 deletions

View File

@ -215,7 +215,7 @@ class WC_Cart {
*/
$cart = WC()->session->get( 'cart', null );
if ( is_null( $cart ) && ( $saved_cart = get_user_meta( get_current_user_id(), '_woocommerce_persistent_cart', true ) ) ) {
if ( is_null( $cart ) && ( $saved_cart = get_user_meta( get_current_user_id(), '_woocommerce_persistent_cart_' . get_current_blog_id(), true ) ) ) {
$cart = $saved_cart['cart'];
$update_cart_session = true;
} elseif ( is_null( $cart ) ) {
@ -314,7 +314,7 @@ class WC_Cart {
* Save the persistent cart when the cart is updated.
*/
public function persistent_cart_update() {
update_user_meta( get_current_user_id(), '_woocommerce_persistent_cart', array(
update_user_meta( get_current_user_id(), '_woocommerce_persistent_cart_' . get_current_blog_id(), array(
'cart' => WC()->session->get( 'cart' ),
) );
}
@ -323,7 +323,7 @@ class WC_Cart {
* Delete the persistent cart permanently.
*/
public function persistent_cart_destroy() {
delete_user_meta( get_current_user_id(), '_woocommerce_persistent_cart' );
delete_user_meta( get_current_user_id(), '_woocommerce_persistent_cart_' . get_current_blog_id() );
}
/*

View File

@ -44,7 +44,6 @@ class WC_Customer_Data_Store extends WC_Data_Store_WP implements WC_Customer_Dat
'comment_shortcuts',
'dismissed_wp_pointers',
'show_welcome_panel',
'_woocommerce_persistent_cart',
'session_tokens',
'nickname',
'description',
@ -81,6 +80,7 @@ class WC_Customer_Data_Store extends WC_Data_Store_WP implements WC_Customer_Dat
$table_prefix = $wpdb->prefix ? $wpdb->prefix : 'wp_';
return ! in_array( $meta->meta_key, $this->internal_meta_keys )
&& 0 !== strpos( $meta->meta_key, '_woocommerce_persistent_cart' )
&& 0 !== strpos( $meta->meta_key, 'closedpostboxes_' )
&& 0 !== strpos( $meta->meta_key, 'metaboxhidden_' )
&& 0 !== strpos( $meta->meta_key, 'manageedit-' )

View File

@ -48,7 +48,7 @@ function wc_empty_cart() {
* @deprecated 2.3
*/
function wc_load_persistent_cart( $user_login, $user ) {
if ( ! $user || ! ( $saved_cart = get_user_meta( $user->ID, '_woocommerce_persistent_cart', true ) ) ) {
if ( ! $user || ! ( $saved_cart = get_user_meta( $user->ID, '_woocommerce_persistent_cart_' . get_current_blog_id(), true ) ) ) {
return;
}