When getting a cart from a session and there are contents as well as contents in the persistant cart, merge the two carts to avoid loosing the persistant cart content.

This commit is contained in:
Gerhard Potgieter 2017-12-05 08:45:52 +02:00
parent 3ed021241f
commit ccb54faf0b
1 changed files with 3 additions and 0 deletions

View File

@ -76,6 +76,9 @@ final class WC_Cart_Session {
$update_cart_session = true;
} elseif ( is_null( $cart ) ) {
$cart = array();
} elseif ( is_array( $cart ) && ( $saved_cart = get_user_meta( get_current_user_id(), '_woocommerce_persistent_cart_' . get_current_blog_id(), true ) ) ) {
$cart = array_merge( $saved_cart['cart'], $cart );
$update_cart_session = true;
}
if ( is_array( $cart ) ) {