This commit is contained in:
Coen Jacobs 2013-09-20 15:51:50 +02:00
commit f0fe86a8ac
18 changed files with 312 additions and 206 deletions

File diff suppressed because one or more lines are too long

View File

@ -515,8 +515,7 @@ ul.wc_coupon_list_block {
width:24px !important;
display: inline-block;
&:after {
.icon;
content: "\e031";
.icon( "\e031" );
line-height: 22px;
}
}
@ -1211,8 +1210,7 @@ ul.wc_coupon_list_block {
margin:0 auto;
color: #999;
&:after {
.icon;
content: "\e026";
.icon( "\e026" );
line-height: 16px;
}
}
@ -1223,8 +1221,7 @@ ul.wc_coupon_list_block {
margin:0 auto;
color: #999;
&:after {
.icon;
content: "\e027";
.icon( "\e027" );
line-height: 16px;
}
}
@ -1359,8 +1356,7 @@ table.wp-list-table {
.ir;
margin:0 auto;
&:before {
.icon;
content: "\e00c";
.icon( "\e00c" );
}
}
span.wc-featured {
@ -1390,8 +1386,7 @@ table.wp-list-table {
.ir;
font-size:1.2em;
&:before {
.icon;
content: "\e006";
.icon( "\e006" );
}
&.grouped:before {
content: "\e002";
@ -1751,8 +1746,7 @@ img.help_tip {
}
.status-enabled {
&:before {
.icon;
content: "\e015";
.icon( "\e015" );
color: @woocommerce;
}
}
@ -1964,9 +1958,8 @@ img.help_tip {
border: 3px dashed #dddddd;
position: relative;
&:after {
.icon;
.icon( "\e00c" );
font-size:2.618em;
content: "\e00c";
line-height: 72px;
color: #ddd;
}
@ -1995,8 +1988,7 @@ img.help_tip {
.ir;
font-size:1.4em;
&:before {
.icon;
content: "\e00c";
.icon( "\e00c" );
background-color: #000;
color: #fff;
}
@ -2005,8 +1997,7 @@ img.help_tip {
.ir;
font-size:1.4em;
&:before {
.icon;
content: "\e013";
.icon( "\e013" );
color:white;
background-color: #000;
-webkit-border-radius:100%;
@ -2110,8 +2101,7 @@ img.help_tip {
border-top: 1px solid #f1f1f1;
padding-left:10px;
&:before {
.iconbefore;
content: "\e028";
.iconbefore( "\e028" );
}
}
@ -2500,9 +2490,8 @@ img.help_tip {
line-height: 22px;
text-decoration: none;
&:before {
.iconbefore;
.iconbefore( "\e036" );
font-size: .8em;
content: "\e036";
color: #999;
}
}
@ -2781,8 +2770,7 @@ img.ui-datepicker-trigger { vertical-align: middle; margin-top: -1px; cursor: po
display: block;
text-decoration: none;
&:before {
.iconbefore;
content: "\e00a";
.iconbefore( "\e00a" );
margin-right:4px;
}
}

View File

@ -90,6 +90,7 @@
width: 100%;
height: 100%;
text-align: center;
content: "\e001";
font-size: 2em;
position: relative;
width: auto;

View File

@ -121,7 +121,7 @@
height:1em;
width:1em;
}
.icon() {
.icon( @glyph: "\e001" ) {
font-family: 'WooCommerce';
speak: none;
font-weight: normal;
@ -137,8 +137,9 @@
width:100%;
height: 100%;
text-align: center;
content: @glyph;
}
.iconbefore() {
.iconbefore( @glyph: "\e001" ) {
font-family: 'WooCommerce';
speak: none;
font-weight: normal;
@ -147,8 +148,9 @@
line-height: 1;
-webkit-font-smoothing: antialiased;
margin-right:7px;
content: @glyph;
}
.iconafter() {
.iconafter( @glyph: "\e001" ) {
font-family: 'WooCommerce';
speak: none;
font-weight: normal;
@ -157,4 +159,5 @@
line-height: 1;
-webkit-font-smoothing: antialiased;
margin-left:7px;
content: @glyph;
}

View File

@ -629,7 +629,7 @@ p.demo_store {
cursor: not-allowed;
&:active {
top: 0;
}
}
}
}
@ -1503,8 +1503,7 @@ p.demo_store {
margin-left: 0;
padding-left: 0;
&:before {
.iconbefore;
content: "\e00a";
.iconbefore( "\e00a" );
}
.count {
float: right;
@ -1540,8 +1539,7 @@ p.demo_store {
color: @tertiarytext;
.border_radius(3px);
&:before {
.iconbefore;
content: "\e013";
.iconbefore( "\e013" );
}
}
}
@ -1577,8 +1575,7 @@ p.demo_store {
.border_radius(3px);
float: left;
&:before {
.iconbefore;
content: "\e013";
.iconbefore( "\e013" );
}
}
}

View File

@ -682,13 +682,16 @@ class WC_Product {
* Returns the price (including tax). Uses customer tax rates. Can work for a specific $qty for more accurate taxes.
*
* @access public
* @param string $price to calculdate, left blank to just use get_price()
* @return string
*/
public function get_price_including_tax( $qty = 1 ) {
public function get_price_including_tax( $qty = 1, $price = '' ) {
global $woocommerce;
$_tax = new WC_Tax();
$price = $this->get_price();
if ( ! $price )
$price = $this->get_price();
if ( $this->is_taxable() ) {
@ -704,7 +707,7 @@ class WC_Product {
$tax_rates = $_tax->get_rates( $this->get_tax_class() );
$base_tax_rates = $_tax->get_shop_base_rate( $this->tax_class );
if ( $woocommerce->customer->is_vat_exempt() ) {
if ( ! empty( $woocommerce->customer ) && $woocommerce->customer->is_vat_exempt() ) {
$base_taxes = $_tax->calc_tax( $price * $qty, $base_tax_rates, true );
$base_tax_amount = array_sum( $base_taxes );
@ -736,11 +739,13 @@ class WC_Product {
* Uses store base tax rates. Can work for a specific $qty for more accurate taxes.
*
* @access public
* @param string $price to calculdate, left blank to just use get_price()
* @return string
*/
public function get_price_excluding_tax( $qty = 1 ) {
public function get_price_excluding_tax( $qty = 1, $price = '' ) {
$price = $this->get_price();
if ( ! $price )
$price = $this->get_price();
if ( $this->is_taxable() && get_option('woocommerce_prices_include_tax') == 'yes' ) {
@ -756,6 +761,32 @@ class WC_Product {
return apply_filters( 'woocommerce_get_price_excluding_tax', $price, $qty, $this );
}
/**
* Get the suffix to display after prices > 0
* @return string
*/
public function get_price_suffix() {
$price_display_suffix = get_option( 'woocommerce_price_display_suffix' );
if ( $price_display_suffix ) {
$price_display_suffix = ' <small class="woocommerce-price-suffix">' . $price_display_suffix . '</small>';
$find = array(
'{price_including_tax}',
'{price_excluding_tax}'
);
$replace = array(
woocommerce_price( $this->get_price_including_tax() ),
woocommerce_price( $this->get_price_excluding_tax() )
);
$price_display_suffix = str_replace( $find, $replace, $price_display_suffix );
}
return apply_filters( 'woocommerce_get_price_suffix', $price_display_suffix, $this );
}
/**
* Returns the price in html format.
*
@ -765,31 +796,36 @@ class WC_Product {
*/
public function get_price_html( $price = '' ) {
if ( $this->get_price() === '' ) {
$tax_display_mode = get_option( 'woocommerce_tax_display_shop' );
$display_price = $tax_display_mode == 'incl' ? $this->get_price_including_tax() : $this->get_price_excluding_tax();
$display_regular_price = $tax_display_mode == 'incl' ? $this->get_price_including_tax( 1, $this->get_regular_price() ) : $this->get_price_excluding_tax( 1, $this->get_regular_price() );
$display_sale_price = $tax_display_mode == 'incl' ? $this->get_price_including_tax( 1, $this->get_sale_price() ) : $this->get_price_excluding_tax( 1, $this->get_sale_price() );
$price = apply_filters( 'woocommerce_empty_price_html', '', $this );
} elseif ( $this->get_price() > 0 ) {
if ( $this->get_price() > 0 ) {
if ( $this->is_on_sale() && $this->get_regular_price() ) {
$price .= $this->get_price_html_from_to( $this->get_regular_price(), $this->get_price() );
$price .= $this->get_price_html_from_to( $display_regular_price, $display_price ) . $this->get_price_suffix();
$price = apply_filters( 'woocommerce_sale_price_html', $price, $this );
} else {
$price .= woocommerce_price( $this->get_price() );
$price .= woocommerce_price( $display_price ) . $this->get_price_suffix();
$price = apply_filters( 'woocommerce_price_html', $price, $this );
}
} elseif ( $this->get_price() === '' ) {
$price = apply_filters( 'woocommerce_empty_price_html', '', $this );
} elseif ( $this->get_price() == 0 ) {
if ( $this->is_on_sale() && $this->get_regular_price() ) {
$price .= $this->get_price_html_from_to( $this->get_regular_price(), __( 'Free!', 'woocommerce' ) );
$price .= $this->get_price_html_from_to( $display_regular_price, __( 'Free!', 'woocommerce' ) );
$price = apply_filters( 'woocommerce_free_sale_price_html', $price, $this );

View File

@ -140,6 +140,25 @@ class WC_Settings_Tax extends WC_Settings_Page {
'default' => sprintf( __( 'Reduced Rate%sZero Rate', 'woocommerce' ), PHP_EOL )
),
array(
'title' => __( 'Display prices in the shop:', 'woocommerce' ),
'id' => 'woocommerce_tax_display_shop',
'default' => 'excl',
'type' => 'select',
'options' => array(
'incl' => __( 'Including tax', 'woocommerce' ),
'excl' => __( 'Excluding tax', 'woocommerce' ),
)
),
array(
'title' => __( 'Price display suffix:', 'woocommerce' ),
'id' => 'woocommerce_price_display_suffix',
'default' => '',
'type' => 'text',
'desc' => __( 'Define text to show after your product prices. This could be, for example, "inc. Vat" to explain your pricing. You can also have prices substituted here using one of the following: <code>{price_including_tax}, {price_excluding_tax}</code>.', 'woocommerce' ),
),
array(
'title' => __( 'Display prices during cart/checkout:', 'woocommerce' ),
'id' => 'woocommerce_tax_display_cart',

View File

@ -482,53 +482,48 @@ class WC_Checkout {
if ( ! empty( $this->posted[ $key ] ) ) {
// Special handling for validation and formatting
switch ( $key ) {
case "billing_postcode" :
case "shipping_postcode" :
// Validation rules
if ( ! empty( $field['validate'] ) && is_array( $field['validate'] ) ) {
foreach ( $field['validate'] as $rule ) {
switch ( $rule ) {
case 'postcode' :
$this->posted[ $key ] = strtoupper( str_replace( ' ', '', $this->posted[ $key ] ) );
$validate_against = $key == 'billing_postcode' ? 'billing_country' : 'shipping_country';
$this->posted[ $key ] = strtoupper( str_replace( ' ', '', $this->posted[ $key ] ) );
if ( ! WC_Validation::is_postcode( $this->posted[ $key ], $_POST[ $fieldset_key . '_country' ] ) ) :
wc_add_error( __( 'Please enter a valid postcode/ZIP.', 'woocommerce' ) );
else :
$this->posted[ $key ] = wc_format_postcode( $this->posted[ $key ], $_POST[ $fieldset_key . '_country' ] );
endif;
break;
case 'phone' :
$this->posted[ $key ] = wc_format_phone_number( $this->posted[ $key ] );
if ( ! WC_Validation::is_postcode( $this->posted[ $key ], $_POST[ $validate_against ] ) )
wc_add_error( '<strong>' . $field['label'] . '</strong> ' . sprintf( __( '(%s) is not a valid postcode/ZIP.', 'woocommerce' ), $this->posted[ $key ] ) );
else
$this->posted[ $key ] = wc_format_postcode( $this->posted[ $key ], $_POST[ $validate_against ] );
if ( ! WC_Validation::is_phone( $this->posted[ $key ] ) )
wc_add_error( '<strong>' . $field['label'] . '</strong> ' . __( 'is not a valid phone number.', 'woocommerce' ) );
break;
case 'email' :
$this->posted[ $key ] = strtolower( $this->posted[ $key ] );
break;
case "billing_state" :
case "shipping_state" :
if ( ! is_email( $this->posted[ $key ] ) )
wc_add_error( '<strong>' . $field['label'] . '</strong> ' . __( 'is not a valid email address.', 'woocommerce' ) );
break;
case 'state' :
// Get valid states
$valid_states = $woocommerce->countries->get_states( $_POST[ $fieldset_key . '_country' ] );
if ( $valid_states )
$valid_state_values = array_flip( array_map( 'strtolower', $valid_states ) );
// Get valid states
$validate_against = $key == 'billing_state' ? 'billing_country' : 'shipping_country';
$valid_states = $woocommerce->countries->get_states( $_POST[ $validate_against ] );
if ( $valid_states )
$valid_state_values = array_flip( array_map( 'strtolower', $valid_states ) );
// Convert value to key if set
if ( isset( $valid_state_values[ strtolower( $this->posted[ $key ] ) ] ) )
$this->posted[ $key ] = $valid_state_values[ strtolower( $this->posted[ $key ] ) ];
// Convert value to key if set
if ( isset( $valid_state_values[ strtolower( $this->posted[ $key ] ) ] ) )
$this->posted[ $key ] = $valid_state_values[ strtolower( $this->posted[ $key ] ) ];
// Only validate if the country has specific state options
if ( $valid_states && sizeof( $valid_states ) > 0 )
if ( ! in_array( $this->posted[ $key ], array_keys( $valid_states ) ) )
wc_add_error( '<strong>' . $field['label'] . '</strong> ' . __( 'is not valid. Please enter one of the following:', 'woocommerce' ) . ' ' . implode( ', ', $valid_states ) );
break;
case "billing_phone" :
$this->posted[ $key ] = wc_format_phone_number( $this->posted[ $key ] );
if ( ! WC_Validation::is_phone( $this->posted[ $key ] ) )
wc_add_error( '<strong>' . $field['label'] . '</strong> ' . __( 'is not a valid number.', 'woocommerce' ) );
break;
case "billing_email" :
$this->posted[ $key ] = strtolower( $this->posted[ $key ] );
if ( ! is_email( $this->posted[ $key ] ) )
wc_add_error( '<strong>' . $field['label'] . '</strong> ' . __( 'is not a valid email address.', 'woocommerce' ) );
break;
// Only validate if the country has specific state options
if ( $valid_states && sizeof( $valid_states ) > 0 )
if ( ! in_array( $this->posted[ $key ], array_keys( $valid_states ) ) )
wc_add_error( '<strong>' . $field['label'] . '</strong> ' . __( 'is not valid. Please enter one of the following:', 'woocommerce' ) . ' ' . implode( ', ', $valid_states ) );
break;
}
}
}
}
}
@ -747,13 +742,14 @@ class WC_Checkout {
if ( ! empty( $_POST[ $input ] ) ) {
return esc_attr( $_POST[ $input ] );
return woocommerce_clean( $_POST[ $input ] );
} else {
$value = apply_filters( 'woocommerce_checkout_get_value', null, $input );
if ( $value ) return $value;
if ( $value )
return $value;
if ( is_user_logged_in() ) {
@ -766,35 +762,22 @@ class WC_Checkout {
return $current_user->user_email;
}
$default_billing_country = apply_filters('default_checkout_country', ($woocommerce->customer->get_country()) ? $woocommerce->customer->get_country() : $woocommerce->countries->get_base_country());
$default_shipping_country = apply_filters('default_checkout_country', ($woocommerce->customer->get_shipping_country()) ? $woocommerce->customer->get_shipping_country() : $woocommerce->countries->get_base_country());
if ( $woocommerce->customer->has_calculated_shipping() ) {
$default_billing_state = apply_filters('default_checkout_state', $woocommerce->customer->get_state());
$default_shipping_state = apply_filters('default_checkout_state', $woocommerce->customer->get_shipping_state());
} else {
$default_billing_state = apply_filters('default_checkout_state', '');
$default_shipping_state = apply_filters('default_checkout_state', '');
switch ( $input ) {
case "billing_country" :
return apply_filters( 'default_checkout_country', $woocommerce->customer->get_country() ? $woocommerce->customer->get_country() : $woocommerce->countries->get_base_country(), 'billing' );
case "billing_state" :
return apply_filters( 'default_checkout_state', $woocommerce->customer->has_calculated_shipping() ? $woocommerce->customer->get_state() : '', 'billing' );
case "billing_postcode" :
return apply_filters( 'default_checkout_postcode', $woocommerce->customer->get_postcode() ? $woocommerce->customer->get_postcode() : '', 'billing' );
case "shipping_country" :
return apply_filters( 'default_checkout_country', $woocommerce->customer->get_shipping_country() ? $woocommerce->customer->get_shipping_country() : $woocommerce->countries->get_base_country(), 'shipping' );
case "shipping_state" :
return apply_filters( 'default_checkout_state', $woocommerce->customer->has_calculated_shipping() ? $woocommerce->customer->get_shipping_state() : '', 'shipping' );
case "shipping_postcode" :
return apply_filters( 'default_checkout_postcode', $woocommerce->customer->get_shipping_postcode() ? $woocommerce->customer->get_shipping_postcode() : '', 'shipping' );
default :
return apply_filters( 'default_checkout_' . $input, '', $input );
}
if ( $input == "billing_country" )
return $default_billing_country;
if ( $input == "billing_state" )
return $default_billing_state;
if ( $input == "billing_postcode" )
return $woocommerce->customer->get_postcode() ? $woocommerce->customer->get_postcode() : '';
if ( $input == "shipping_country" )
return $default_shipping_country;
if ( $input == "shipping_state" )
return $default_shipping_state;
if ( $input == "shipping_postcode" )
return $woocommerce->customer->get_shipping_postcode() ? $woocommerce->customer->get_shipping_postcode() : '';
}
}
}

View File

@ -696,56 +696,58 @@ class WC_Countries {
public function get_default_address_fields() {
$fields = array(
'country' => array(
'type' => 'country',
'label' => __( 'Country', 'woocommerce' ),
'required' => true,
'class' => array( 'form-row-wide', 'address-field', 'update_totals_on_change' ),
'type' => 'country',
'label' => __( 'Country', 'woocommerce' ),
'required' => true,
'class' => array( 'form-row-wide', 'address-field', 'update_totals_on_change' ),
),
'first_name' => array(
'label' => __( 'First Name', 'woocommerce' ),
'required' => true,
'class' => array( 'form-row-first' ),
'label' => __( 'First Name', 'woocommerce' ),
'required' => true,
'class' => array( 'form-row-first' ),
),
'last_name' => array(
'label' => __( 'Last Name', 'woocommerce' ),
'required' => true,
'class' => array( 'form-row-last' ),
'clear' => true
'label' => __( 'Last Name', 'woocommerce' ),
'required' => true,
'class' => array( 'form-row-last' ),
'clear' => true
),
'company' => array(
'label' => __( 'Company Name', 'woocommerce' ),
'class' => array( 'form-row-wide' ),
'label' => __( 'Company Name', 'woocommerce' ),
'class' => array( 'form-row-wide' ),
),
'address_1' => array(
'label' => __( 'Address', 'woocommerce' ),
'placeholder' => _x( 'Street address', 'placeholder', 'woocommerce' ),
'required' => true,
'class' => array( 'form-row-wide', 'address-field' )
'label' => __( 'Address', 'woocommerce' ),
'placeholder' => _x( 'Street address', 'placeholder', 'woocommerce' ),
'required' => true,
'class' => array( 'form-row-wide', 'address-field' )
),
'address_2' => array(
'placeholder' => _x( 'Apartment, suite, unit etc. (optional)', 'placeholder', 'woocommerce' ),
'class' => array( 'form-row-wide', 'address-field' ),
'required' => false
'placeholder' => _x( 'Apartment, suite, unit etc. (optional)', 'placeholder', 'woocommerce' ),
'class' => array( 'form-row-wide', 'address-field' ),
'required' => false
),
'city' => array(
'label' => __( 'Town / City', 'woocommerce' ),
'placeholder' => __( 'Town / City', 'woocommerce' ),
'required' => true,
'class' => array( 'form-row-wide', 'address-field' )
'label' => __( 'Town / City', 'woocommerce' ),
'placeholder' => __( 'Town / City', 'woocommerce' ),
'required' => true,
'class' => array( 'form-row-wide', 'address-field' )
),
'state' => array(
'type' => 'state',
'label' => __( 'State / County', 'woocommerce' ),
'placeholder' => __( 'State / County', 'woocommerce' ),
'required' => true,
'class' => array( 'form-row-first', 'address-field' )
'type' => 'state',
'label' => __( 'State / County', 'woocommerce' ),
'placeholder' => __( 'State / County', 'woocommerce' ),
'required' => true,
'class' => array( 'form-row-first', 'address-field' ),
'validate' => array( 'state' )
),
'postcode' => array(
'label' => __( 'Postcode / Zip', 'woocommerce' ),
'placeholder' => __( 'Postcode / Zip', 'woocommerce' ),
'required' => true,
'class' => array( 'form-row-last', 'address-field' ),
'clear' => true
'label' => __( 'Postcode / Zip', 'woocommerce' ),
'placeholder' => __( 'Postcode / Zip', 'woocommerce' ),
'required' => true,
'class' => array( 'form-row-last', 'address-field' ),
'clear' => true,
'validate' => array( 'postcode' )
),
);
@ -1120,7 +1122,8 @@ class WC_Countries {
'label' => __( 'Phone', 'woocommerce' ),
'required' => true,
'class' => array( 'form-row-last' ),
'clear' => true
'clear' => true,
'validate' => array( 'phone' ),
);
}

View File

@ -51,48 +51,69 @@ class WC_Form_Handler {
$user_id = get_current_user_id();
if ( $user_id <= 0 ) return;
if ( $user_id <= 0 )
return;
$load_address = isset( $wp->query_vars['edit-address'] ) ? sanitize_key( $wp->query_vars['edit-address'] ) : 'billing';
$address = $woocommerce->countries->get_address_fields( esc_attr( $_POST[ $load_address . '_country' ] ), $load_address . '_' );
foreach ($address as $key => $field) :
foreach ( $address as $key => $field ) {
if (!isset($field['type'])) $field['type'] = 'text';
if ( ! isset( $field['type'] ) )
$field['type'] = 'text';
// Get Value
switch ($field['type']) :
switch ( $field['type'] ) {
case "checkbox" :
$_POST[$key] = isset($_POST[$key]) ? 1 : 0;
$_POST[ $key ] = isset( $_POST[ $key ] ) ? 1 : 0;
break;
default :
$_POST[$key] = isset($_POST[$key]) ? woocommerce_clean($_POST[$key]) : '';
$_POST[ $key ] = isset( $_POST[ $key ] ) ? woocommerce_clean( $_POST[ $key ] ) : '';
break;
endswitch;
}
// Hook to allow modification of value
$_POST[$key] = apply_filters('woocommerce_process_myaccount_field_' . $key, $_POST[$key]);
$_POST[ $key ] = apply_filters( 'woocommerce_process_myaccount_field_' . $key, $_POST[ $key ] );
// Validation: Required fields
if ( isset($field['required']) && $field['required'] && empty($_POST[$key]) ) wc_add_error( $field['label'] . ' ' . __( 'is a required field.', 'woocommerce' ) );
if ( ! empty( $field['required'] ) && empty( $_POST[ $key ] ) )
wc_add_error( $field['label'] . ' ' . __( 'is a required field.', 'woocommerce' ) );
// Postcode
if ($key=='billing_postcode' || $key=='shipping_postcode') :
if ( ! WC_Validation::is_postcode( $_POST[$key], $_POST[ $load_address . '_country' ] ) ) :
wc_add_error( __( 'Please enter a valid postcode/ZIP.', 'woocommerce' ) );
else :
$_POST[$key] = wc_format_postcode( $_POST[$key], $_POST[ $load_address . '_country' ] );
endif;
endif;
// Validation rules
if ( ! empty( $field['validate'] ) && is_array( $field['validate'] ) ) {
foreach ( $field['validate'] as $rule ) {
switch ( $rule ) {
case 'postcode' :
$_POST[ $key ] = strtoupper( str_replace( ' ', '', $_POST[ $key ] ) );
endforeach;
if ( ! WC_Validation::is_postcode( $_POST[ $key ], $_POST[ $load_address . '_country' ] ) ) :
wc_add_error( __( 'Please enter a valid postcode/ZIP.', 'woocommerce' ) );
else :
$_POST[ $key ] = wc_format_postcode( $_POST[ $key ], $_POST[ $load_address . '_country' ] );
endif;
break;
case 'phone' :
$_POST[ $key ] = wc_format_phone_number( $_POST[ $key ] );
if ( ! WC_Validation::is_phone( $_POST[ $key ] ) )
wc_add_error( '<strong>' . $field['label'] . '</strong> ' . __( 'is not a valid phone number.', 'woocommerce' ) );
break;
case 'email' :
$_POST[ $key ] = strtolower( $_POST[ $key ] );
if ( ! is_email( $_POST[ $key ] ) )
wc_add_error( '<strong>' . $field['label'] . '</strong> ' . __( 'is not a valid email address.', 'woocommerce' ) );
break;
}
}
}
}
if ( wc_error_count() == 0 ) {
foreach ($address as $key => $field) :
update_user_meta( $user_id, $key, $_POST[$key] );
endforeach;
foreach ( $address as $key => $field )
update_user_meta( $user_id, $key, $_POST[ $key ] );
wc_add_message( __( 'Address changed successfully.', 'woocommerce' ) );

View File

@ -151,7 +151,6 @@ class WC_Product_Grouped extends WC_Product {
return apply_filters( 'woocommerce_is_purchasable', false, $this );
}
/**
* Returns the price in html format.
*
@ -174,11 +173,18 @@ class WC_Product_Grouped extends WC_Product {
$min_price = '';
}
if ( sizeof( $child_prices ) > 1 ) $price .= $this->get_price_html_from_text();
if ( sizeof( $child_prices ) > 1 )
$price .= $this->get_price_html_from_text();
$price .= woocommerce_price( $min_price );
if ( $min_price ) {
$display_price = $tax_display_mode == 'incl' ? $this->get_price_including_tax( 1, $min_price ) : $this->get_price_excluding_tax( 1, $min_price );
$price = apply_filters( 'woocommerce_grouped_price_html', $price, $this );
$price .= woocommerce_price( $display_price ) . $this->get_price_suffix();
$price = apply_filters( 'woocommerce_grouped_price_html', $price, $this );
} else {
$price = apply_filters( 'woocommerce_grouped_empty_price_html', '', $this );
}
return apply_filters( 'woocommerce_get_price_html', $price, $this );
}

View File

@ -197,12 +197,12 @@ class WC_Product_Variable extends WC_Product {
if ( $this->get_variation_price( 'max' ) === '' || $this->get_price() === '' )
$this->variable_product_sync( $this->id );
$tax_display_mode = get_option( 'woocommerce_tax_display_shop' );
$display_price = $tax_display_mode == 'incl' ? $this->get_price_including_tax() : $this->get_price_excluding_tax();
$display_min_variation_regular_price = $tax_display_mode == 'incl' ? $this->get_price_including_tax( 1, $this->get_variation_regular_price( 'min' ) ) : $this->get_price_excluding_tax( 1, $this->get_variation_regular_price( 'min' ) );
// Get the price
if ( $this->get_price() === '' ) {
$price = apply_filters( 'woocommerce_variable_empty_price_html', '', $this );
} elseif ( $this->get_price() > 0 ) {
if ( $this->get_price() > 0 ) {
// Only show 'from' if the min price varies from the max price
if ( $this->get_variation_price( 'min' ) !== $this->get_variation_price( 'max' ) )
@ -210,18 +210,22 @@ class WC_Product_Variable extends WC_Product {
if ( $this->is_on_sale() && $this->get_variation_regular_price( 'min' ) !== $this->get_price() ) {
$price .= $this->get_price_html_from_to( $this->get_variation_regular_price( 'min' ), $this->get_price() );
$price .= $this->get_price_html_from_to( $display_min_variation_regular_price, $display_price ) . $this->get_price_suffix();
$price = apply_filters( 'woocommerce_variable_sale_price_html', $price, $this );
} else {
$price .= woocommerce_price( $this->get_price() );
$price .= woocommerce_price( $display_price ) . $this->get_price_suffix();
$price = apply_filters('woocommerce_variable_price_html', $price, $this);
}
} elseif ( $this->get_price() === '' ) {
$price = apply_filters( 'woocommerce_variable_empty_price_html', '', $this );
} elseif ( $this->get_price() == 0 ) {
// Only show 'from' if the min price varies from the max price
@ -230,7 +234,7 @@ class WC_Product_Variable extends WC_Product {
if ( $this->is_on_sale() && $this->get_variation_regular_price( 'min' ) > 0 ) {
$price .= $this->get_price_html_from_to( $this->get_variation_regular_price( 'min' ), __( 'Free!', 'woocommerce' ) );
$price .= $this->get_price_html_from_to( $display_min_variation_regular_price, __( 'Free!', 'woocommerce' ) );
$price = apply_filters( 'woocommerce_variable_free_sale_price_html', $price, $this );

View File

@ -231,20 +231,28 @@ class WC_Product_Variation extends WC_Product {
*/
public function get_price_html( $price = '' ) {
$tax_display_mode = get_option( 'woocommerce_tax_display_shop' );
$display_price = $tax_display_mode == 'incl' ? $this->get_price_including_tax() : $this->get_price_excluding_tax();
$display_regular_price = $tax_display_mode == 'incl' ? $this->get_price_including_tax( 1, $this->get_regular_price() ) : $this->get_price_excluding_tax( 1, $this->get_regular_price() );
$display_sale_price = $tax_display_mode == 'incl' ? $this->get_price_including_tax( 1, $this->get_sale_price() ) : $this->get_price_excluding_tax( 1, $this->get_sale_price() );
if ( $this->get_price() !== '' ) {
if ( $this->is_on_sale() ) {
$price = '<del>' . woocommerce_price( $this->get_regular_price() ) . '</del> <ins>' . woocommerce_price( $this->get_sale_price() ) . '</ins>';
$price = '<del>' . woocommerce_price( $display_regular_price ) . '</del> <ins>' . woocommerce_price( $display_sale_price ) . '</ins>' . $this->get_price_suffix();
$price = apply_filters( 'woocommerce_variation_sale_price_html', $price, $this );
} elseif ( $this->get_price() > 0 ) {
$price = woocommerce_price( $this->get_price() );
$price = woocommerce_price( $display_price ) . $this->get_price_suffix();
$price = apply_filters( 'woocommerce_variation_price_html', $price, $this );
} else {
$price = __( 'Free!', 'woocommerce' );
$price = apply_filters( 'woocommerce_variation_free_price_html', $price, $this );
}

View File

@ -175,7 +175,7 @@ class WC_Tax {
$tax_class = sanitize_title( $tax_class );
/* Checkout uses customer location for the tax rates. Also, if shipping has been calculated, use the customers address. */
if ( ( defined('WOOCOMMERCE_CHECKOUT') && WOOCOMMERCE_CHECKOUT ) || $woocommerce->customer->has_calculated_shipping() ) {
if ( ( defined('WOOCOMMERCE_CHECKOUT') && WOOCOMMERCE_CHECKOUT ) || ( ! empty( $woocommerce->customer ) && $woocommerce->customer->has_calculated_shipping() ) ) {
list( $country, $state, $postcode, $city ) = $woocommerce->customer->get_taxable_address();
@ -192,7 +192,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 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'
$matched_tax_rates = get_option( 'woocommerce_prices_include_tax' ) == 'yes' || get_option( 'woocommerce_default_customer_address' ) == 'base'
? $this->get_shop_base_rate( $tax_class )
: array();
@ -235,7 +235,7 @@ class WC_Tax {
$tax_class = $shipping_tax_class == 'standard' ? '' : $shipping_tax_class;
}
if ( ( defined('WOOCOMMERCE_CHECKOUT') && WOOCOMMERCE_CHECKOUT ) || $woocommerce->customer->has_calculated_shipping() ) {
if ( ( defined('WOOCOMMERCE_CHECKOUT') && WOOCOMMERCE_CHECKOUT ) || ( ! empty( $woocommerce->customer ) && $woocommerce->customer->has_calculated_shipping() ) ) {
list( $country, $state, $postcode, $city ) = $woocommerce->customer->get_taxable_address();
@ -243,7 +243,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 excluding tax however should just not add any taxes, as they will be added during checkout
if ( $woocommerce->cart->prices_include_tax || get_option( 'woocommerce_default_customer_address' ) == 'base' ) {
if ( get_option( 'woocommerce_prices_include_tax' ) == 'yes' || get_option( 'woocommerce_default_customer_address' ) == 'base' ) {
$country = $woocommerce->countries->get_base_country();
$state = $woocommerce->countries->get_base_state();
$postcode = '';

View File

@ -202,6 +202,23 @@ class WC_Shipping_Local_Delivery extends WC_Shipping_Method {
if ( in_array( $this->clean( $package['destination']['postcode'] ), $codes ) )
$found_match = true;
// Pattern match
if ( ! $found_match ) {
$customer_postcode = $this->clean( $package['destination']['postcode'] );
foreach ($codes as $c) {
$pattern = '/^'.str_replace('_', '[0-9a-zA-Z]', $c).'$/i';
if(preg_match($pattern, $customer_postcode)) {
$found_match = true;
break;
}
}
}
// Wildcard search
if ( ! $found_match ) {

View File

@ -155,6 +155,31 @@ class WC_Shortcode_My_Account {
$address = $woocommerce->countries->get_address_fields( get_user_meta( get_current_user_id(), $load_address . '_country', true ), $load_address . '_' );
// Prepare values
foreach ( $address as $key => $field ) {
$value = get_user_meta( get_current_user_id(), $key, true );
if ( ! $value ) {
switch( $key ) {
case 'billing_email' :
case 'shipping_email' :
$value = $current_user->user_email;
break;
case 'billing_country' :
case 'shipping_country' :
$value = $woocommerce->countries->get_base_country();
break;
case 'billing_state' :
case 'shipping_state' :
$value = $woocommerce->countries->get_base_state();
break;
}
}
$address[ $key ]['value'] = apply_filters( 'woocommerce_my_account_edit_address_field_value', $value, $key, $load_address );
}
woocommerce_get_template( 'myaccount/form-edit-address.php', array(
'load_address' => $load_address,
'address' => apply_filters( 'woocommerce_address_to_edit', $address )

View File

@ -166,6 +166,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
== Changelog ==
= 2.1 - x =
* Feature - Define whether prices should be shown incl. or excl. of tax, and add an optional suffix.
* Feature - Split frontend styles into separate appearance/layout stylesheets and removed the enable/disable option.
* Feature - Added woocommerce-smallscreen.css to optimise default layout on handheld devices.
* Feature - Bulk edit increase / decrease variation prices by fixed or percentage values
@ -201,6 +202,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
* Tweak - Disabled button styles.
* Tweak - Hooks for overriding default email inline styles.
* Tweak - Flat rate shipping support for percentage factor of additional costs.
* Tweak - local delivery _ pattern matching for postcodes. e.g. NG1___ would match NG1 1AA but not NG10 1AA.
* Fix - Changed MyException to Exception in Checkout class as MyException class does not exist in WooCommerce
* Fix - Default cart widget styling on non-wc pages.
* Fix - Rounding for mijireh tax ex. price.

View File

@ -4,7 +4,7 @@
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 1.6.4
* @version 2.1.0
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@ -18,9 +18,9 @@ get_currentuserinfo();
<?php wc_print_messages(); ?>
<?php if (!$load_address) : ?>
<?php if ( ! $load_address ) : ?>
<?php woocommerce_get_template('myaccount/my-address.php'); ?>
<?php woocommerce_get_template( 'myaccount/my-address.php' ); ?>
<?php else : ?>
@ -28,18 +28,11 @@ get_currentuserinfo();
<h3><?php echo apply_filters( 'woocommerce_my_account_edit_address_title', $page_title ); ?></h3>
<?php
foreach ($address as $key => $field) :
$value = (isset($_POST[$key])) ? $_POST[$key] : get_user_meta( get_current_user_id(), $key, true );
<?php foreach ( $address as $key => $field ) : ?>
// Default values
if (!$value && ($key=='billing_email' || $key=='shipping_email')) $value = $current_user->user_email;
if (!$value && ($key=='billing_country' || $key=='shipping_country')) $value = $woocommerce->countries->get_base_country();
if (!$value && ($key=='billing_state' || $key=='shipping_state')) $value = $woocommerce->countries->get_base_state();
<?php woocommerce_form_field( $key, $field, ! empty( $_POST[ $key ] ) ? woocommerce_clean( $_POST[ $key ] ) : $field['value'] ); ?>
woocommerce_form_field( $key, $field, $value );
endforeach;
?>
<?php endforeach; ?>
<p>
<input type="submit" class="button" name="save_address" value="<?php _e( 'Save Address', 'woocommerce' ); ?>" />