Tax display tweaks. Default customer address option.

This commit is contained in:
Mike Jolley 2012-12-13 16:38:40 +00:00
parent 5a8e25d743
commit aa3afb7a85
5 changed files with 24 additions and 11 deletions

View File

@ -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' ),

View File

@ -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;
}

View File

@ -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;
}
/**

View File

@ -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 .= ' <small class="tax_label">' . $woocommerce->countries->ex_tax_or_vat() . '</small>';
} 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 .= ' <small class="tax_label">' . $woocommerce->countries->inc_tax_or_vat() . '</small>';
}

View File

@ -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 = '';