dynamic required
This commit is contained in:
parent
07753da578
commit
cc1c77db20
|
@ -636,6 +636,7 @@ jQuery(document).ready(function($) {
|
|||
/* Localisation */
|
||||
var locale_json = woocommerce_params.locale.replace(/"/g, '"');
|
||||
var locale = $.parseJSON( locale_json );
|
||||
var required = ' <abbr class="required" title="' + woocommerce_params.required_text + '">*</abbr>';
|
||||
|
||||
// Handle locale
|
||||
$('body').bind('country_to_state_changing', function( event, country, wrapper ){
|
||||
|
@ -653,8 +654,23 @@ jQuery(document).ready(function($) {
|
|||
var field = thisform.find('#billing_state_field, #shipping_state_field');
|
||||
|
||||
if ( thislocale['state']['label'] ) {
|
||||
field.find('label').text( 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 );
|
||||
|
||||
}
|
||||
|
||||
var postcodefield = thisform.find('#billing_postcode_field, #shipping_postcode_field');
|
||||
|
@ -662,16 +678,47 @@ jQuery(document).ready(function($) {
|
|||
|
||||
// City Handling
|
||||
if ( thislocale['city'] ) {
|
||||
|
||||
if ( thislocale['city']['label'] ) {
|
||||
cityfield.find('label').text( 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').text( 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
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -163,6 +163,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
|
|||
* Improved edit my address page when accessed directly
|
||||
* Extra hooks in carts/totals
|
||||
* Tweaked attributes page/labels
|
||||
* Added required * to checkout fields, dynamically for locales
|
||||
|
||||
= 1.4.4 - 18/02/2012 =
|
||||
* Fix for remove coupon links after ajax update of shipping
|
||||
|
|
|
@ -654,7 +654,7 @@ if (!function_exists('woocommerce_form_field')) {
|
|||
|
||||
if ((isset($args['clear']) && $args['clear'])) $after = '<div class="clear"></div>'; else $after = '';
|
||||
|
||||
$required = ( $args['required'] ) ? ' <span class="required">*</span>' : '';
|
||||
$required = ( $args['required'] ) ? ' <abbr class="required" title="' . esc_attr__( 'required', 'woocommerce' ) . '">*</abbr>' : '';
|
||||
|
||||
switch ($args['type']) :
|
||||
case "country" :
|
||||
|
@ -721,7 +721,7 @@ if (!function_exists('woocommerce_form_field')) {
|
|||
|
||||
$field = '<p class="form-row '.implode(' ', $args['class']).'" id="'.$key.'_field">
|
||||
<input type="'.$args['type'].'" class="input-checkbox" name="'.$key.'" id="'.$key.'" value="1" '.checked($value, 1, false).' />
|
||||
<label for="'.$key.'" class="checkbox '.implode(' ', $args['label_class']).'">'.$args['label'].'</label>' . $required . '
|
||||
<label for="'.$key.'" class="checkbox '.implode(' ', $args['label_class']).'">'.$args['label'] . $required . '</label>
|
||||
</p>'.$after;
|
||||
|
||||
break;
|
||||
|
|
|
@ -899,6 +899,7 @@ class Woocommerce {
|
|||
$woocommerce_params = array(
|
||||
'countries' => $states,
|
||||
'select_state_text' => __('Select an option…', 'woocommerce'),
|
||||
'required_text' => esc_attr__( 'required', 'woocommerce' ),
|
||||
'plugin_url' => $this->plugin_url(),
|
||||
'ajax_url' => (!is_ssl()) ? str_replace('https', 'http', admin_url('admin-ajax.php')) : admin_url('admin-ajax.php'),
|
||||
'get_variation_nonce' => wp_create_nonce("get-variation"),
|
||||
|
|
Loading…
Reference in New Issue