Started work on locale options for ticket #316.
Plan is to combine locale options with the checkout array so fields can be overridden.
This commit is contained in:
parent
4e85d2a8c5
commit
feb9afd30b
|
@ -151,21 +151,33 @@ jQuery(document).ready(function($) {
|
||||||
var value = $(state_box).val();
|
var value = $(state_box).val();
|
||||||
|
|
||||||
if (states[country]) {
|
if (states[country]) {
|
||||||
var options = '';
|
if (states[country].length == 0) {
|
||||||
var state = states[country];
|
|
||||||
for(var index in state) {
|
// Empty array means state field is not used
|
||||||
options = options + '<option value="' + index + '">' + state[index] + '</option>';
|
$(state_box).parent().hide();
|
||||||
}
|
$(state_box).replaceWith('<input type="hidden" class="hidden" name="' + input_name + '" id="' + input_id + '" value="" />');
|
||||||
if ($(state_box).is('input')) {
|
|
||||||
// Change for select
|
} else {
|
||||||
$(state_box).replaceWith('<select name="' + input_name + '" id="' + input_id + '"></select>');
|
|
||||||
state_box = $('#' + $(this).attr('rel'));
|
|
||||||
}
|
|
||||||
$(state_box).html( '<option value="">' + woocommerce_params.select_state_text + '</option>' + options);
|
|
||||||
|
|
||||||
$(state_box).val(value);
|
var options = '';
|
||||||
|
var state = states[country];
|
||||||
|
for(var index in state) {
|
||||||
|
options = options + '<option value="' + index + '">' + state[index] + '</option>';
|
||||||
|
}
|
||||||
|
if ($(state_box).is('input')) {
|
||||||
|
// Change for select
|
||||||
|
$(state_box).replaceWith('<select name="' + input_name + '" id="' + input_id + '"></select>');
|
||||||
|
state_box = $('#' + $(this).attr('rel'));
|
||||||
|
}
|
||||||
|
$(state_box).html( '<option value="">' + woocommerce_params.select_state_text + '</option>' + options);
|
||||||
|
|
||||||
|
$(state_box).val(value);
|
||||||
|
$(state_box).parent().show();
|
||||||
|
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($(state_box).is('select')) {
|
if ($(state_box).is('select, .hidden')) {
|
||||||
|
$(state_box).parent().show();
|
||||||
$(state_box).replaceWith('<input type="text" class="input-text" placeholder="' + woocommerce_params.state_text + '" name="' + input_name + '" id="' + input_id + '" />');
|
$(state_box).replaceWith('<input type="text" class="input-text" placeholder="' + woocommerce_params.state_text + '" name="' + input_name + '" id="' + input_id + '" />');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -34,48 +34,56 @@ class woocommerce_checkout {
|
||||||
'label' => __('First Name', 'woothemes'),
|
'label' => __('First Name', 'woothemes'),
|
||||||
'placeholder' => __('First Name', 'woothemes'),
|
'placeholder' => __('First Name', 'woothemes'),
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'class' => array('form-row-first')
|
'class' => array('form-row-first'),
|
||||||
|
'position' => 1,
|
||||||
),
|
),
|
||||||
'billing_last_name' => array(
|
'billing_last_name' => array(
|
||||||
'label' => __('Last Name', 'woothemes'),
|
'label' => __('Last Name', 'woothemes'),
|
||||||
'placeholder' => __('Last Name', 'woothemes'),
|
'placeholder' => __('Last Name', 'woothemes'),
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'class' => array('form-row-last')
|
'class' => array('form-row-last'),
|
||||||
|
'position' => 2,
|
||||||
),
|
),
|
||||||
'billing_company' => array(
|
'billing_company' => array(
|
||||||
'label' => __('Company', 'woothemes'),
|
'label' => __('Company', 'woothemes'),
|
||||||
'placeholder' => __('Company', 'woothemes')
|
'placeholder' => __('Company', 'woothemes'),
|
||||||
|
'position' => 3,
|
||||||
),
|
),
|
||||||
'billing_address_1' => array(
|
'billing_address_1' => array(
|
||||||
'label' => __('Address', 'woothemes'),
|
'label' => __('Address', 'woothemes'),
|
||||||
'placeholder' => __('Address 1', 'woothemes'),
|
'placeholder' => __('Address 1', 'woothemes'),
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'class' => array('form-row-first')
|
'class' => array('form-row-first'),
|
||||||
|
'position' => 4,
|
||||||
),
|
),
|
||||||
'billing_address_2' => array(
|
'billing_address_2' => array(
|
||||||
'label' => __('Address 2', 'woothemes'),
|
'label' => __('Address 2', 'woothemes'),
|
||||||
'placeholder' => __('Address 2', 'woothemes'),
|
'placeholder' => __('Address 2', 'woothemes'),
|
||||||
'class' => array('form-row-last'),
|
'class' => array('form-row-last'),
|
||||||
'label_class' => array('hidden')
|
'label_class' => array('hidden'),
|
||||||
|
'position' => 5,
|
||||||
),
|
),
|
||||||
'billing_city' => array(
|
'billing_city' => array(
|
||||||
'label' => __('City', 'woothemes'),
|
'label' => __('City', 'woothemes'),
|
||||||
'placeholder' => __('City', 'woothemes'),
|
'placeholder' => __('City', 'woothemes'),
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'class' => array('form-row-first')
|
'class' => array('form-row-first'),
|
||||||
|
'position' => 6,
|
||||||
),
|
),
|
||||||
'billing_postcode' => array(
|
'billing_postcode' => array(
|
||||||
'label' => __('Postcode', 'woothemes'),
|
'label' => __('Postcode', 'woothemes'),
|
||||||
'placeholder' => __('Postcode', 'woothemes'),
|
'placeholder' => __('Postcode', 'woothemes'),
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'class' => array('form-row-last update_totals_on_change')
|
'class' => array('form-row-last update_totals_on_change'),
|
||||||
|
'position' => 7,
|
||||||
),
|
),
|
||||||
'billing_country' => array(
|
'billing_country' => array(
|
||||||
'type' => 'country',
|
'type' => 'country',
|
||||||
'label' => __('Country', 'woothemes'),
|
'label' => __('Country', 'woothemes'),
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'class' => array('form-row-first update_totals_on_change'),
|
'class' => array('form-row-first update_totals_on_change'),
|
||||||
'rel' => 'billing_state'
|
'rel' => 'billing_state',
|
||||||
|
'position' => 8,
|
||||||
),
|
),
|
||||||
'billing_state' => array(
|
'billing_state' => array(
|
||||||
'type' => 'state',
|
'type' => 'state',
|
||||||
|
@ -83,19 +91,22 @@ class woocommerce_checkout {
|
||||||
'label' => __('State/County', 'woothemes'),
|
'label' => __('State/County', 'woothemes'),
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'class' => array('form-row-last update_totals_on_change'),
|
'class' => array('form-row-last update_totals_on_change'),
|
||||||
'rel' => 'billing_country'
|
'rel' => 'billing_country',
|
||||||
|
'position' => 9,
|
||||||
),
|
),
|
||||||
'billing_email' => array(
|
'billing_email' => array(
|
||||||
'label' => __('Email Address', 'woothemes'),
|
'label' => __('Email Address', 'woothemes'),
|
||||||
'placeholder' => __('you@yourdomain.com', 'woothemes'),
|
'placeholder' => __('you@yourdomain.com', 'woothemes'),
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'class' => array('form-row-first')
|
'class' => array('form-row-first'),
|
||||||
|
'position' => 10,
|
||||||
),
|
),
|
||||||
'billing_phone' => array(
|
'billing_phone' => array(
|
||||||
'label' => __('Phone', 'woothemes'),
|
'label' => __('Phone', 'woothemes'),
|
||||||
'placeholder' => __('Phone number', 'woothemes'),
|
'placeholder' => __('Phone number', 'woothemes'),
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'class' => array('form-row-last')
|
'class' => array('form-row-last'),
|
||||||
|
'position' => 11,
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ class woocommerce_countries {
|
||||||
'AT' => __('Austria', 'woothemes'),
|
'AT' => __('Austria', 'woothemes'),
|
||||||
'AU' => __('Australia', 'woothemes'),
|
'AU' => __('Australia', 'woothemes'),
|
||||||
'AW' => __('Aruba', 'woothemes'),
|
'AW' => __('Aruba', 'woothemes'),
|
||||||
'AX' => __('Aland Islands', 'woothemes'),
|
'AX' => __('Aaland Islands', 'woothemes'),
|
||||||
'AZ' => __('Azerbaijan', 'woothemes'),
|
'AZ' => __('Azerbaijan', 'woothemes'),
|
||||||
'BA' => __('Bosnia and Herzegovina', 'woothemes'),
|
'BA' => __('Bosnia and Herzegovina', 'woothemes'),
|
||||||
'BB' => __('Barbados', 'woothemes'),
|
'BB' => __('Barbados', 'woothemes'),
|
||||||
|
@ -114,7 +114,6 @@ class woocommerce_countries {
|
||||||
'GW' => __('Guinea-Bissau', 'woothemes'),
|
'GW' => __('Guinea-Bissau', 'woothemes'),
|
||||||
'GY' => __('Guyana', 'woothemes'),
|
'GY' => __('Guyana', 'woothemes'),
|
||||||
'HK' => __('Hong Kong S.A.R., China', 'woothemes'),
|
'HK' => __('Hong Kong S.A.R., China', 'woothemes'),
|
||||||
//'HM' => __('Heard Island and McDonald Islands', 'woothemes'), // Uninhabitted :)
|
|
||||||
'HN' => __('Honduras', 'woothemes'),
|
'HN' => __('Honduras', 'woothemes'),
|
||||||
'HR' => __('Croatia', 'woothemes'),
|
'HR' => __('Croatia', 'woothemes'),
|
||||||
'HT' => __('Haiti', 'woothemes'),
|
'HT' => __('Haiti', 'woothemes'),
|
||||||
|
@ -325,6 +324,7 @@ class woocommerce_countries {
|
||||||
'SK' => __('Saskatchewan', 'woothemes') ,
|
'SK' => __('Saskatchewan', 'woothemes') ,
|
||||||
'YT' => __('Yukon Territory', 'woothemes')
|
'YT' => __('Yukon Territory', 'woothemes')
|
||||||
),
|
),
|
||||||
|
'DE' => array(),
|
||||||
'US' => array(
|
'US' => array(
|
||||||
'AL' => __('Alabama', 'woothemes') ,
|
'AL' => __('Alabama', 'woothemes') ,
|
||||||
'AK' => __('Alaska', 'woothemes') ,
|
'AK' => __('Alaska', 'woothemes') ,
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* WooCommerce Localisation
|
||||||
|
*
|
||||||
|
* Contains country-specific rules
|
||||||
|
*
|
||||||
|
* @class woocommerce_localisation
|
||||||
|
* @package WooCommerce
|
||||||
|
* @category Class
|
||||||
|
* @author WooThemes
|
||||||
|
*/
|
||||||
|
class woocommerce_localisation {
|
||||||
|
|
||||||
|
var $locales;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*/
|
||||||
|
function __construct() {
|
||||||
|
|
||||||
|
$this->locales => array(
|
||||||
|
|
||||||
|
'DE' => array(
|
||||||
|
'billing_fields'=> array(
|
||||||
|
'billing_city' => array(
|
||||||
|
'class' => array('form-row-last'),
|
||||||
|
'position' => 7,
|
||||||
|
),
|
||||||
|
'billing_postcode' => array(
|
||||||
|
'class' => array('form-row-first update_totals_on_change'),
|
||||||
|
'position' => 6
|
||||||
|
),
|
||||||
|
'billing_state' => array(
|
||||||
|
'required' => false
|
||||||
|
),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'shipping_fields'=> array(
|
||||||
|
'shipping_city' => array(
|
||||||
|
'class' => array('form-row-last'),
|
||||||
|
'position' => 7,
|
||||||
|
),
|
||||||
|
'shipping_postcode' => array(
|
||||||
|
'class' => array('form-row-first update_totals_on_change'),
|
||||||
|
'position' => 6
|
||||||
|
),
|
||||||
|
'shipping_state' => array(
|
||||||
|
'required' => false
|
||||||
|
),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue