From ca1b9c334c109152a2406cecd21ab947485c2c18 Mon Sep 17 00:00:00 2001 From: juangadiel Date: Fri, 12 Dec 2014 17:18:16 -0400 Subject: [PATCH 1/2] Update class-wc-checkout.php fixes issue #6940 Check if the cart needs shipping before updating the user shipping address. This fixes the issue (#6940) of the shipping address being updated with the user billing address when purchasing a virtual product. --- includes/class-wc-checkout.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/includes/class-wc-checkout.php b/includes/class-wc-checkout.php index 7409018ad65..ccdeedab230 100644 --- a/includes/class-wc-checkout.php +++ b/includes/class-wc-checkout.php @@ -7,7 +7,7 @@ * @class WC_Cart * @version 2.1.0 * @package WooCommerce/Classes - * @category Class + * @category Class * @author WooThemes */ class WC_Checkout { @@ -300,8 +300,10 @@ class WC_Checkout { foreach ( $billing_address as $key => $value ) { update_user_meta( $this->customer_id, 'billing_' . $key, $value ); } - foreach ( $shipping_address as $key => $value ) { - update_user_meta( $this->customer_id, 'shipping_' . $key, $value ); + if (WC()->cart->needs_shipping()) { + foreach ( $shipping_address as $key => $value ) { + update_user_meta( $this->customer_id, 'shipping_' . $key, $value ); + } } } do_action( 'woocommerce_checkout_update_user_meta', $this->customer_id, $this->posted ); From de1466779b2e89101ec04fa1852ac74004ebfd25 Mon Sep 17 00:00:00 2001 From: Juan Gadiel Rosado Colon Date: Sat, 20 Dec 2014 20:29:09 -0400 Subject: [PATCH 2/2] Fixes issue #6940 Check if the cart needs shipping before updating the user shipping address. This fixes the issue (#6940) of the shipping address being updated with the user billing address when purchasing a virtual product. --- includes/class-wc-checkout.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-wc-checkout.php b/includes/class-wc-checkout.php index ccdeedab230..1fd63ef7e37 100644 --- a/includes/class-wc-checkout.php +++ b/includes/class-wc-checkout.php @@ -300,7 +300,7 @@ class WC_Checkout { foreach ( $billing_address as $key => $value ) { update_user_meta( $this->customer_id, 'billing_' . $key, $value ); } - if (WC()->cart->needs_shipping()) { + if ( WC()->cart->needs_shipping() ) { foreach ( $shipping_address as $key => $value ) { update_user_meta( $this->customer_id, 'shipping_' . $key, $value ); }