Vietnam locale and support for hiding fields

This commit is contained in:
Mike Jolley 2012-03-14 20:35:42 +00:00
parent cc7fc5117a
commit 81de864a13
6 changed files with 72 additions and 77 deletions

View File

@ -707,78 +707,52 @@ jQuery(document).ready(function($) {
} else {
var thislocale = locale['default'];
}
// State Handling
if ( thislocale['state'] ) {
var field = thisform.find('#billing_state_field, #shipping_state_field');
if ( thislocale['state']['label'] ) {
field.find('label').html( thislocale['state']['label'] );
}
field.find('label abbr').remove();
if ( typeof thislocale['state']['required'] == 'undefined' || thislocale['state']['required'] == true ) {
field.find('label').append( required );
}
} else {
if (field.find('label abbr').size()==0) field.find('label').append( required );
}
// Handle locale fields
var locale_fields = {
'address_2' : '#billing_address_2_field, #shipping_address_2_field',
'state' : '#billing_state_field, #shipping_state_field',
'postcode' : '#billing_postcode_field, #shipping_postcode_field',
'city' : '#billing_city_field, #shipping_city_field'
};
$.each( locale_fields, function( key, value ) {
var field = thisform.find( value );
if ( thislocale[key] ) {
if ( thislocale[key]['label'] ) {
field.find('label').html( thislocale[key]['label'] );
}
field.find('label abbr').remove();
if ( typeof thislocale[key]['required'] == 'undefined' || thislocale[key]['required'] == true ) {
field.find('label').append( required );
}
if ( key !== 'state' ) {
if ( thislocale[key]['hidden'] == true ) {
field.fadeOut(200).find('input').val('');
} else {
field.fadeIn(500);
}
}
} else {
if ( locale['default'][key]['required'] == true ) {
if (field.find('label abbr').size()==0) field.find('label').append( required );
}
if ( key !== 'state' && (typeof locale['default'][key]['hidden'] == 'undefined' || locale['default'][key]['hidden'] == false) ) {
field.fadeIn(500);
}
}
});
var postcodefield = thisform.find('#billing_postcode_field, #shipping_postcode_field');
var cityfield = thisform.find('#billing_city_field, #shipping_city_field');
// City Handling
if ( thislocale['city'] ) {
if ( thislocale['city']['label'] ) {
cityfield.find('label').html( thislocale['city']['label'] );
}
cityfield.find('label abbr').remove();
if ( typeof thislocale['city']['required'] == 'undefined' || thislocale['city']['required'] == true ) {
cityfield.find('label').append( required );
}
} else {
if (cityfield.find('label abbr').size()==0) cityfield.find('label').append( required );
}
// Postcode Handling
if ( thislocale['postcode'] ) {
if ( thislocale['postcode']['label'] ) {
postcodefield.find('label').html( thislocale['postcode']['label'] );
}
postcodefield.find('label abbr').remove();
if ( typeof thislocale['postcode']['required'] == 'undefined' || thislocale['postcode']['required'] == true ) {
postcodefield.find('label').append( required );
}
} else {
if (postcodefield.find('label abbr').size()==0) postcodefield.find('label').append( required );
}
// Re-order postcode/city
if ( thislocale['postcode_before_city'] ) {

File diff suppressed because one or more lines are too long

View File

@ -240,7 +240,7 @@ class WC_Cart {
if (is_array($coupon->customer_email) && sizeof($coupon->customer_email)>0) {
if (is_user_logged_in()) {
$current_user = wp_get_current_user();
//$check_emails[] = $current_user->user_email;
$check_emails[] = $current_user->user_email;
}
$check_emails[] = $posted['billing_email'];

View File

@ -406,7 +406,8 @@ class WC_Countries {
'AA' => __('Americas', 'woocommerce') ,
'AE' => __('Europe', 'woocommerce') ,
'AP' => __('Pacific', 'woocommerce')
)
),
'VN' => array()
);
}
@ -575,6 +576,7 @@ class WC_Countries {
'SE' => $postcode_before_city,
'TR' => "{name}\n{company}\n{address_1}\n{address_2}\n{postcode} {city} {state}\n{country}",
'US' => "{name}\n{company}\n{address_1}\n{address_2}\n{city}, {state} {postcode}\n{country}",
'VN' => "{name}\n{company}\n{address_1}\n{city}\n{country}",
));
endif;
@ -817,20 +819,38 @@ class WC_Countries {
'label' => __('County', 'woocommerce')
)
),
'VN' => array(
'state' => array(
'required' => false
),
'postcode' => array(
'required' => false,
'hidden' => true
),
'address_2' => array(
'required' => false,
'hidden' => true
)
),
));
$this->locale = array_intersect_key($this->locale, $this->get_allowed_countries());
$this->locale['default'] = apply_filters('woocommerce_localisation_default_address_fields', array(
'address_2' => array(
'required' => false
),
'postcode' => array(
'label' => __('Postcode/Zip', 'woocommerce')
'label' => __('Postcode/Zip', 'woocommerce'),
'required' => true
),
'city' => array(
'label' => __('Town/City', 'woocommerce')
'label' => __('Town/City', 'woocommerce'),
'required' => true
),
'state' => array(
'label' => __('State/County', 'woocommerce')
'label' => __('State/County', 'woocommerce'),
'required' => true
)
));

View File

@ -245,7 +245,7 @@ class WC_Customer {
}
/** Depreciated */
class woocommerce_customer extends WC_Coupon {
class woocommerce_customer extends WC_Customer {
public function __construct() {
_deprecated_function( 'woocommerce_customer', '1.4', 'WC_Customer()' );
parent::__construct();

View File

@ -175,6 +175,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
* Optimised queries with no_found_rows
* Template Loader - Support for taxonomy-product_cat-SLUG.php template files
* Stock checker works with items on multiple rows
* Vietnam locale and support for hiding fields
= 1.5.1 - 08/03/2012 =
* Persistent (logged-in) customer carts (thanks dominic-p)