diff --git a/admin/settings/settings-init.php b/admin/settings/settings-init.php index 9bb5560bfc9..03b2c33ad2f 100644 --- a/admin/settings/settings-init.php +++ b/admin/settings/settings-init.php @@ -996,12 +996,24 @@ $woocommerce_settings['tax'] = apply_filters('woocommerce_tax_settings', array( 'default' => 'shipping', 'type' => 'select', 'options' => array( - 'shipping' => __( 'Shipping address', 'woocommerce' ), - 'billing' => __( 'Billing address', 'woocommerce' ), + 'shipping' => __( 'Customer shipping address', 'woocommerce' ), + 'billing' => __( 'Customer billing address', 'woocommerce' ), 'base' => __( 'Shop base address', 'woocommerce' ) ), ), + array( + 'title' => __( 'Default Customer Address:', 'woocommerce' ), + 'id' => 'woocommerce_default_customer_address', + 'desc_tip' => __( 'This option determines the customers default address (before they input their own).', 'woocommerce' ), + 'default' => 'base', + 'type' => 'select', + 'options' => array( + '' => __( 'No address', 'woocommerce' ), + 'base' => __( 'Shop base address', 'woocommerce' ), + ), + ), + array( 'title' => __( 'Shipping Tax Class:', 'woocommerce' ), 'desc' => __( 'Optionally control which tax class shipping gets, or leave it so shipping tax is based on the cart items themselves.', 'woocommerce' ), diff --git a/admin/settings/settings-save.php b/admin/settings/settings-save.php index 67473174bcf..bf0bd914c28 100644 --- a/admin/settings/settings-save.php +++ b/admin/settings/settings-save.php @@ -76,7 +76,7 @@ function woocommerce_update_options( $options ) { if ( isset( $_POST[ $value['id'] ] ) ) { $option_value = esc_attr( $_POST[ $value['id'] ] ); } else { - $option_value = ''; + $option_value = ''; } } elseif ( $value['id'] == 'woocommerce_price_num_decimals' ) { @@ -188,7 +188,7 @@ function woocommerce_update_options( $options ) { // Now save the options foreach( $update_options as $name => $value ) - update_option( $name, $value, true ); + update_option( $name, $value ); return true; } \ No newline at end of file diff --git a/admin/woocommerce-admin-settings.php b/admin/woocommerce-admin-settings.php index fe98e3cc010..974bd04d8cb 100644 --- a/admin/woocommerce-admin-settings.php +++ b/admin/woocommerce-admin-settings.php @@ -553,10 +553,10 @@ function woocommerce_settings_get_option( $option_name, $default = '' ) { if ( is_array( $option_value ) ) $option_value = array_map( 'stripslashes', $option_value ); - elseif ( $option_value ) + elseif ( ! is_null( $option_value ) ) $option_value = stripslashes( $option_value ); - return $option_value == null ? $default : $option_value; + return $option_value === null ? $default : $option_value; } /** diff --git a/classes/class-wc-cart.php b/classes/class-wc-cart.php index df781b18330..ac16da38867 100644 --- a/classes/class-wc-cart.php +++ b/classes/class-wc-cart.php @@ -1978,7 +1978,7 @@ class WC_Cart { $row_price = $_product->get_price_excluding_tax( $quantity ); $product_subtotal = woocommerce_price( $row_price ); - if ( $this->prices_include_tax ) + if ( $this->prices_include_tax && $this->tax_total > 0 ) $product_subtotal .= ' ' . $woocommerce->countries->ex_tax_or_vat() . ''; } else { @@ -1986,7 +1986,7 @@ class WC_Cart { $row_price = $_product->get_price_including_tax( $quantity ); $product_subtotal = woocommerce_price( $row_price ); - if ( ! $this->prices_include_tax ) + if ( ! $this->prices_include_tax && $this->tax_total > 0 ) $product_subtotal .= ' ' . $woocommerce->countries->inc_tax_or_vat() . ''; } diff --git a/classes/class-wc-tax.php b/classes/class-wc-tax.php index 2c249a7dbe9..64728776bfd 100644 --- a/classes/class-wc-tax.php +++ b/classes/class-wc-tax.php @@ -138,8 +138,9 @@ class WC_Tax { } else { // Prices which include tax should always use the base rate if we don't know where the user is located - // Prices exlcuding tax however should just not add any taxes, as they will be added during checkout - $matched_tax_rates = $woocommerce->cart->prices_include_tax + // Prices excluding tax however should just not add any taxes, as they will be added during checkout. + // The woocommerce_default_customer_address option (when set to base) is also used here. + $matched_tax_rates = $woocommerce->cart->prices_include_tax || get_option( 'woocommerce_default_customer_address' ) == 'base' ? $this->get_shop_base_rate( $tax_class ) : array(); @@ -190,7 +191,7 @@ class WC_Tax { // Prices which include tax should always use the base rate if we don't know where the user is located // Prices exlcuding tax however should just not add any taxes, as they will be added during checkout - if ( $woocommerce->cart->prices_include_tax ) { + if ( $woocommerce->cart->prices_include_tax || get_option( 'woocommerce_default_customer_address' ) == 'base' ) { $country = $woocommerce->countries->get_base_country(); $state = $woocommerce->countries->get_base_state(); $postcode = '';