From 6c9f9ea4242784139e78eb0fa0013d151cabd89f Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Thu, 3 Jan 2019 15:30:21 +0000 Subject: [PATCH] phpcs --- includes/class-wc-cart-session.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/includes/class-wc-cart-session.php b/includes/class-wc-cart-session.php index 01eade27190..b5d38b15a0f 100644 --- a/includes/class-wc-cart-session.php +++ b/includes/class-wc-cart-session.php @@ -70,7 +70,6 @@ final class WC_Cart_Session { $update_cart_session = false; // Flag to indicate the stored cart should be updated. $order_again = false; // Flag to indicate whether this is a re-order. - $cart = WC()->session->get( 'cart', null ); $merge_saved_cart = (bool) get_user_meta( get_current_user_id(), '_woocommerce_load_saved_cart_after_login', true ); @@ -121,7 +120,8 @@ final class WC_Cart_Session { } else { // Put session data into array. Run through filter so other plugins can load their own session data. $session_data = array_merge( - $values, array( + $values, + array( 'data' => $product, ) ); @@ -148,7 +148,7 @@ final class WC_Cart_Session { // If this is a re-order, redirect to the cart page to get rid of the `order_again` query string. if ( $order_again ) { - wp_redirect( wc_get_page_permalink( 'cart' ) ); + wp_safe_redirect( wc_get_page_permalink( 'cart' ) ); exit; } } @@ -219,7 +219,9 @@ final class WC_Cart_Session { public function persistent_cart_update() { if ( get_current_user_id() && apply_filters( 'woocommerce_persistent_cart_enabled', true ) ) { update_user_meta( - get_current_user_id(), '_woocommerce_persistent_cart_' . get_current_blog_id(), array( + get_current_user_id(), + '_woocommerce_persistent_cart_' . get_current_blog_id(), + array( 'cart' => $this->get_cart_for_session(), ) ); @@ -327,8 +329,10 @@ final class WC_Cart_Session { $cart_id = WC()->cart->generate_cart_id( $product_id, $variation_id, $variations, $cart_item_data ); $product_data = wc_get_product( $variation_id ? $variation_id : $product_id ); $cart[ $cart_id ] = apply_filters( - 'woocommerce_add_order_again_cart_item', array_merge( - $cart_item_data, array( + 'woocommerce_add_order_again_cart_item', + array_merge( + $cart_item_data, + array( 'key' => $cart_id, 'product_id' => $product_id, 'variation_id' => $variation_id, @@ -337,7 +341,8 @@ final class WC_Cart_Session { 'data' => $product_data, 'data_hash' => wc_get_cart_item_data_hash( $product_data ), ) - ), $cart_id + ), + $cart_id ); }