Working on locales, also added 'chosen' as an option for the checkout

This commit is contained in:
Mike Jolley 2011-12-15 19:22:15 +00:00
parent c616e67d66
commit fe3242558a
11 changed files with 592 additions and 65 deletions

View File

@ -198,6 +198,14 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings',
'checkboxgroup' => ''
),
array(
'desc' => __( 'Enable "chosen" (enhanced select input) for country selection inputs', 'woothemes' ),
'id' => 'woocommerce_enable_chosen',
'std' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => ''
),
array(
'desc' => __( 'Enable jQuery UI (used by the price slider widget)', 'woothemes' ),
'id' => 'woocommerce_enable_jquery_ui',

375
assets/css/chosen.css Normal file
View File

@ -0,0 +1,375 @@
/* @group Base */
.chzn-container {
font-size: 13px;
position: relative;
display: inline-block;
zoom: 1;
*display: inline;
}
.chzn-container .chzn-drop {
background: #fff;
border: 1px solid #aaa;
border-top: 0;
position: absolute;
top: 29px;
left: 0;
-webkit-box-shadow: 0 4px 5px rgba(0,0,0,.15);
-moz-box-shadow : 0 4px 5px rgba(0,0,0,.15);
-o-box-shadow : 0 4px 5px rgba(0,0,0,.15);
box-shadow : 0 4px 5px rgba(0,0,0,.15);
z-index: 999;
}
/* @end */
/* @group Single Chosen */
.chzn-container-single .chzn-single {
background-color: #fff;
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eeeeee), color-stop(0.5, white));
background-image: -webkit-linear-gradient(center bottom, #eeeeee 0%, white 50%);
background-image: -moz-linear-gradient(center bottom, #eeeeee 0%, white 50%);
background-image: -o-linear-gradient(top, #eeeeee 0%,#ffffff 50%);
background-image: -ms-linear-gradient(top, #eeeeee 0%,#ffffff 50%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#ffffff',GradientType=0 );
background-image: linear-gradient(top, #eeeeee 0%,#ffffff 50%);
-webkit-border-radius: 4px;
-moz-border-radius : 4px;
border-radius : 4px;
-moz-background-clip : padding;
-webkit-background-clip: padding-box;
background-clip : padding-box;
border: 1px solid #aaa;
display: block;
overflow: hidden;
white-space: nowrap;
position: relative;
height: 26px;
line-height: 26px;
padding: 0 0 0 8px;
color: #444;
text-decoration: none;
}
.chzn-container-single .chzn-single span {
margin-right: 26px;
display: block;
overflow: hidden;
white-space: nowrap;
-o-text-overflow: ellipsis;
-ms-text-overflow: ellipsis;
text-overflow: ellipsis;
}
.chzn-container-single .chzn-single abbr {
display: block;
position: absolute;
right: 26px;
top: 8px;
width: 12px;
height: 13px;
font-size: 1px;
background: url(../images/chosen-sprite.png) right top no-repeat;
}
.chzn-container-single .chzn-single abbr:hover {
background-position: right -11px;
}
.chzn-container-single .chzn-single div {
-webkit-border-radius: 0 4px 4px 0;
-moz-border-radius : 0 4px 4px 0;
border-radius : 0 4px 4px 0;
-moz-background-clip : padding;
-webkit-background-clip: padding-box;
background-clip : padding-box;
background: #ccc;
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #ccc), color-stop(0.6, #eee));
background-image: -webkit-linear-gradient(center bottom, #ccc 0%, #eee 60%);
background-image: -moz-linear-gradient(center bottom, #ccc 0%, #eee 60%);
background-image: -o-linear-gradient(bottom, #ccc 0%, #eee 60%);
background-image: -ms-linear-gradient(top, #cccccc 0%,#eeeeee 60%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cccccc', endColorstr='#eeeeee',GradientType=0 );
background-image: linear-gradient(top, #cccccc 0%,#eeeeee 60%);
border-left: 1px solid #aaa;
position: absolute;
right: 0;
top: 0;
display: block;
height: 100%;
width: 18px;
}
.chzn-container-single .chzn-single div b {
background: url('../images/chosen-sprite.png') no-repeat 0 1px;
display: block;
width: 100%;
height: 100%;
}
.chzn-container-single .chzn-search {
padding: 3px 4px;
position: relative;
margin: 0;
white-space: nowrap;
z-index: 1010;
}
.chzn-container-single .chzn-search input {
background: #fff url('../images/chosen-sprite.png') no-repeat 100% -22px;
background: url('../images/chosen-sprite.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee));
background: url('../images/chosen-sprite.png') no-repeat 100% -22px, -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%);
background: url('../images/chosen-sprite.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%);
background: url('../images/chosen-sprite.png') no-repeat 100% -22px, -o-linear-gradient(bottom, white 85%, #eeeeee 99%);
background: url('../images/chosen-sprite.png') no-repeat 100% -22px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%);
background: url('../images/chosen-sprite.png') no-repeat 100% -22px, linear-gradient(top, #ffffff 85%,#eeeeee 99%);
margin: 1px 0;
padding: 4px 20px 4px 5px;
outline: 0;
border: 1px solid #aaa;
font-family: sans-serif;
font-size: 1em;
width: 100% !important;
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box; /* Opera/IE 8+ */
}
.chzn-container-single .chzn-drop {
-webkit-border-radius: 0 0 4px 4px;
-moz-border-radius : 0 0 4px 4px;
border-radius : 0 0 4px 4px;
-moz-background-clip : padding;
-webkit-background-clip: padding-box;
background-clip : padding-box;
}
/* @end */
.chzn-container-single-nosearch .chzn-search input {
position: absolute;
left: -9000px;
}
/* @group Multi Chosen */
.chzn-container-multi .chzn-choices {
background-color: #fff;
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee));
background-image: -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%);
background-image: -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%);
background-image: -o-linear-gradient(bottom, white 85%, #eeeeee 99%);
background-image: -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#eeeeee',GradientType=0 );
background-image: linear-gradient(top, #ffffff 85%,#eeeeee 99%);
border: 1px solid #aaa;
margin: 0;
padding: 0;
cursor: text;
overflow: hidden;
height: auto !important;
height: 1%;
position: relative;
}
.chzn-container-multi .chzn-choices li {
float: left;
list-style: none;
}
.chzn-container-multi .chzn-choices .search-field {
white-space: nowrap;
margin: 0;
padding: 0;
}
.chzn-container-multi .chzn-choices .search-field input {
color: #666;
background: transparent !important;
border: 0 !important;
padding: 5px;
margin: 1px 0;
outline: 0;
-webkit-box-shadow: none;
-moz-box-shadow : none;
-o-box-shadow : none;
box-shadow : none;
}
.chzn-container-multi .chzn-choices .search-field .default {
color: #999;
}
.chzn-container-multi .chzn-choices .search-choice {
-webkit-border-radius: 3px;
-moz-border-radius : 3px;
border-radius : 3px;
-moz-background-clip : padding;
-webkit-background-clip: padding-box;
background-clip : padding-box;
background-color: #e4e4e4;
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #e4e4e4), color-stop(0.7, #eeeeee));
background-image: -webkit-linear-gradient(center bottom, #e4e4e4 0%, #eeeeee 70%);
background-image: -moz-linear-gradient(center bottom, #e4e4e4 0%, #eeeeee 70%);
background-image: -o-linear-gradient(bottom, #e4e4e4 0%, #eeeeee 70%);
background-image: -ms-linear-gradient(top, #e4e4e4 0%,#eeeeee 70%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#e4e4e4', endColorstr='#eeeeee',GradientType=0 );
background-image: linear-gradient(top, #e4e4e4 0%,#eeeeee 70%);
color: #333;
border: 1px solid #b4b4b4;
line-height: 13px;
padding: 3px 19px 3px 6px;
margin: 3px 0 3px 5px;
position: relative;
}
.chzn-container-multi .chzn-choices .search-choice span {
cursor: default;
}
.chzn-container-multi .chzn-choices .search-choice-focus {
background: #d4d4d4;
}
.chzn-container-multi .chzn-choices .search-choice .search-choice-close {
display: block;
position: absolute;
right: 3px;
top: 4px;
width: 12px;
height: 13px;
font-size: 1px;
background: url(../images/chosen-sprite.png) right top no-repeat;
}
.chzn-container-multi .chzn-choices .search-choice .search-choice-close:hover {
background-position: right -11px;
}
.chzn-container-multi .chzn-choices .search-choice-focus .search-choice-close {
background-position: right -11px;
}
/* @end */
/* @group Results */
.chzn-container .chzn-results {
margin: 0 4px 4px 0;
max-height: 190px;
padding: 0 0 0 4px;
position: relative;
overflow-x: hidden;
overflow-y: auto;
}
.chzn-container-multi .chzn-results {
margin: -1px 0 0;
padding: 0;
}
.chzn-container .chzn-results li {
display: none;
line-height: 80%;
padding: 7px 7px 8px;
margin: 0;
list-style: none;
}
.chzn-container .chzn-results .active-result {
cursor: pointer;
display: list-item;
}
.chzn-container .chzn-results .highlighted {
background: #3875d7;
color: #fff;
}
.chzn-container .chzn-results li em {
background: #feffde;
font-style: normal;
}
.chzn-container .chzn-results .highlighted em {
background: transparent;
}
.chzn-container .chzn-results .no-results {
background: #f4f4f4;
display: list-item;
}
.chzn-container .chzn-results .group-result {
cursor: default;
color: #999;
font-weight: bold;
}
.chzn-container .chzn-results .group-option {
padding-left: 20px;
}
.chzn-container-multi .chzn-drop .result-selected {
display: none;
}
/* @end */
/* @group Active */
.chzn-container-active .chzn-single {
-webkit-box-shadow: 0 0 5px rgba(0,0,0,.3);
-moz-box-shadow : 0 0 5px rgba(0,0,0,.3);
-o-box-shadow : 0 0 5px rgba(0,0,0,.3);
box-shadow : 0 0 5px rgba(0,0,0,.3);
border: 1px solid #5897fb;
}
.chzn-container-active .chzn-single-with-drop {
border: 1px solid #aaa;
-webkit-box-shadow: 0 1px 0 #fff inset;
-moz-box-shadow : 0 1px 0 #fff inset;
-o-box-shadow : 0 1px 0 #fff inset;
box-shadow : 0 1px 0 #fff inset;
background-color: #eee;
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, white), color-stop(0.5, #eeeeee));
background-image: -webkit-linear-gradient(center bottom, white 0%, #eeeeee 50%);
background-image: -moz-linear-gradient(center bottom, white 0%, #eeeeee 50%);
background-image: -o-linear-gradient(bottom, white 0%, #eeeeee 50%);
background-image: -ms-linear-gradient(top, #ffffff 0%,#eeeeee 50%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#eeeeee',GradientType=0 );
background-image: linear-gradient(top, #ffffff 0%,#eeeeee 50%);
-webkit-border-bottom-left-radius : 0;
-webkit-border-bottom-right-radius: 0;
-moz-border-radius-bottomleft : 0;
-moz-border-radius-bottomright: 0;
border-bottom-left-radius : 0;
border-bottom-right-radius: 0;
}
.chzn-container-active .chzn-single-with-drop div {
background: transparent;
border-left: none;
}
.chzn-container-active .chzn-single-with-drop div b {
background-position: -18px 1px;
}
.chzn-container-active .chzn-choices {
-webkit-box-shadow: 0 0 5px rgba(0,0,0,.3);
-moz-box-shadow : 0 0 5px rgba(0,0,0,.3);
-o-box-shadow : 0 0 5px rgba(0,0,0,.3);
box-shadow : 0 0 5px rgba(0,0,0,.3);
border: 1px solid #5897fb;
}
.chzn-container-active .chzn-choices .search-field input {
color: #111 !important;
}
/* @end */
/* @group Disabled Support */
.chzn-disabled {
cursor: default;
opacity:0.5 !important;
}
.chzn-disabled .chzn-single {
cursor: default;
}
.chzn-disabled .chzn-choices .search-choice .search-choice-close {
cursor: default;
}
/* @group Right to Left */
.chzn-rtl { direction:rtl;text-align: right; }
.chzn-rtl .chzn-single { padding-left: 0; padding-right: 8px; }
.chzn-rtl .chzn-single span { margin-left: 26px; margin-right: 0; }
.chzn-rtl .chzn-single div {
left: 0; right: auto;
border-left: none; border-right: 1px solid #aaaaaa;
-webkit-border-radius: 4px 0 0 4px;
-moz-border-radius : 4px 0 0 4px;
border-radius : 4px 0 0 4px;
}
.chzn-rtl .chzn-single abbr {
left: 26px;
right: auto;
}
.chzn-rtl .chzn-choices li { float: right; }
.chzn-rtl .chzn-choices .search-choice { padding: 3px 6px 3px 19px; margin: 3px 5px 3px 0; }
.chzn-rtl .chzn-choices .search-choice .search-choice-close { left: 5px; right: auto; background-position: right top;}
.chzn-rtl.chzn-container-single .chzn-results { margin-left: 4px; margin-right: 0; padding-left: 0; padding-right: 4px; }
.chzn-rtl .chzn-results .group-option { padding-left: 0; padding-right: 20px; }
.chzn-rtl.chzn-container-active .chzn-single-with-drop div { border-right: none; }
.chzn-rtl .chzn-search input {
background: url('../images/chosen-sprite.png') no-repeat -38px -22px, #ffffff;
background: url('../images/chosen-sprite.png') no-repeat -38px -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, white), color-stop(0.99, #eeeeee));
background: url('../images/chosen-sprite.png') no-repeat -38px -22px, -webkit-linear-gradient(center bottom, white 85%, #eeeeee 99%);
background: url('../images/chosen-sprite.png') no-repeat -38px -22px, -moz-linear-gradient(center bottom, white 85%, #eeeeee 99%);
background: url('../images/chosen-sprite.png') no-repeat -38px -22px, -o-linear-gradient(bottom, white 85%, #eeeeee 99%);
background: url('../images/chosen-sprite.png') no-repeat -38px -22px, -ms-linear-gradient(top, #ffffff 85%,#eeeeee 99%);
background: url('../images/chosen-sprite.png') no-repeat -38px -22px, linear-gradient(top, #ffffff 85%,#eeeeee 99%);
padding: 4px 5px 4px 20px;
}
/* @end */

1
assets/css/chosen.min.css vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -897,3 +897,14 @@
};
root.get_side_border_padding = get_side_border_padding;
}).call(this);
jQuery(function(){
// Frontend Chosen selects
jQuery("select.country_select, select.state_select").chosen();
$('body').bind('country_to_state_changed', function(){
jQuery("select.state_select").chosen().trigger("liszt:updated");
});
});

File diff suppressed because one or more lines are too long

View File

@ -155,6 +155,7 @@ jQuery(document).ready(function($) {
// Empty array means state field is not used
$(state_box).parent().hide();
$(state_box).parent().find('.chzn-container').remove();
$(state_box).replaceWith('<input type="hidden" class="hidden" name="' + input_name + '" id="' + input_id + '" value="" />');
} else {
@ -166,7 +167,7 @@ jQuery(document).ready(function($) {
}
if ($(state_box).is('input')) {
// Change for select
$(state_box).replaceWith('<select name="' + input_name + '" id="' + input_id + '"></select>');
$(state_box).replaceWith('<select name="' + input_name + '" id="' + input_id + '" class="state_select"></select>');
state_box = $('#' + $(this).attr('rel'));
}
$(state_box).html( '<option value="">' + woocommerce_params.select_state_text + '</option>' + options);
@ -178,10 +179,13 @@ jQuery(document).ready(function($) {
} else {
if ($(state_box).is('select, .hidden')) {
$(state_box).parent().show();
$(state_box).parent().find('.chzn-container').remove();
$(state_box).replaceWith('<input type="text" class="input-text" placeholder="' + woocommerce_params.state_text + '" name="' + input_name + '" id="' + input_id + '" />');
}
}
$('body').trigger('country_to_state_changed');
}).change();
/* Tabs */

File diff suppressed because one or more lines are too long

View File

@ -16,6 +16,7 @@ class woocommerce_checkout {
var $shipping_fields;
var $must_create_account;
var $creating_account;
var $localisation;
/** constructor */
function __construct () {
@ -27,61 +28,60 @@ class woocommerce_checkout {
if (get_option('woocommerce_enable_guest_checkout')=='yes' || is_user_logged_in()) $this->must_create_account = false;
// Load Locales
include_once('localisation.class.php');
$this->localisation = &new woocommerce_localisation();
// Define billing fields in an array. This can be hooked into and filtered if you wish to change/add anything.
$this->billing_fields = apply_filters('woocommerce_billing_fields', array(
'billing_first_name' => array(
'name' =>'billing_first_name',
'label' => __('First Name', 'woothemes'),
'placeholder' => __('First Name', 'woothemes'),
'required' => true,
'class' => array('form-row-first'),
'position' => 1,
),
'billing_last_name' => array(
'label' => __('Last Name', 'woothemes'),
'placeholder' => __('Last Name', 'woothemes'),
'required' => true,
'class' => array('form-row-last'),
'position' => 2,
),
'billing_company' => array(
'label' => __('Company', 'woothemes'),
'placeholder' => __('Company', 'woothemes'),
'label' => __('Company Name', 'woothemes'),
'placeholder' => __('Company (optional)', 'woothemes'),
'position' => 3,
),
'billing_address_1' => array(
'label' => __('Address', 'woothemes'),
'placeholder' => __('Address 1', 'woothemes'),
'required' => true,
'class' => array('form-row-first'),
'position' => 4,
),
'billing_address_2' => array(
'label' => __('Address 2', 'woothemes'),
'placeholder' => __('Address 2', 'woothemes'),
'placeholder' => __('Address 2 (optional)', 'woothemes'),
'class' => array('form-row-last'),
'label_class' => array('hidden'),
'position' => 5,
),
'billing_city' => array(
'label' => __('City', 'woothemes'),
'placeholder' => __('City', 'woothemes'),
'required' => true,
'class' => array('form-row-first'),
'position' => 6,
),
'billing_postcode' => array(
'label' => __('Postcode', 'woothemes'),
'placeholder' => __('Postcode', 'woothemes'),
'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(
'type' => 'country',
'label' => __('Country', 'woothemes'),
'required' => true,
'class' => array('form-row-first update_totals_on_change'),
'class' => array('form-row-first', 'update_totals_on_change', 'country_select'),
'rel' => 'billing_state',
'position' => 8,
),
@ -90,20 +90,18 @@ class woocommerce_checkout {
'name' =>'billing_state',
'label' => __('State/County', 'woothemes'),
'required' => true,
'class' => array('form-row-last update_totals_on_change'),
'class' => array('form-row-last', 'update_totals_on_change'),
'rel' => 'billing_country',
'position' => 9,
),
'billing_email' => array(
'label' => __('Email Address', 'woothemes'),
'placeholder' => __('you@yourdomain.com', 'woothemes'),
'required' => true,
'class' => array('form-row-first'),
'position' => 10,
),
'billing_phone' => array(
'label' => __('Phone', 'woothemes'),
'placeholder' => __('Phone number', 'woothemes'),
'required' => true,
'class' => array('form-row-last'),
'position' => 11,
@ -150,23 +148,30 @@ class woocommerce_checkout {
'label' => __('Postcode', 'woothemes'),
'placeholder' => __('Postcode', 'woothemes'),
'required' => true,
'class' => array('form-row-last update_totals_on_change')
'class' => array('form-row-last', 'update_totals_on_change')
),
'shipping_country' => array(
'type' => 'country',
'label' => __('Country', 'woothemes'),
'required' => true,
'class' => array('form-row-first update_totals_on_change'),
'class' => array('form-row-first', 'update_totals_on_change'),
'rel' => 'shipping_state'
),
'shipping_state' => array(
'type' => 'state',
'label' => __('State/County', 'woothemes'),
'required' => true,
'class' => array('form-row-last update_totals_on_change'),
'class' => array('form-row-last', 'update_totals_on_change'),
'rel' => 'shipping_country'
)
));
uasort($this->billing_fields, array(&$this, 'sort_by_position'));
}
function sort_by_position($a, $b) {
return $a['position'] - $b['position'];
}
/** Output the billing information form */
@ -297,8 +302,6 @@ class woocommerce_checkout {
);
$args = wp_parse_args( $args, $defaults );
if ($args['required']) $required = ' <span class="required">*</span>'; else $required = '';
if (in_array('form-row-last', $args['class'])) $after = '<div class="clear"></div>'; else $after = '';
@ -308,8 +311,8 @@ class woocommerce_checkout {
case "country" :
$field = '<p class="form-row '.implode(' ', $args['class']).'">
<label for="'.$key.'" class="'.implode(' ', $args['label_class']).'">'.$args['label'].$required.'</label>
<select name="'.$key.'" id="'.$key.'" class="country_to_state" rel="'.$args['rel'].'">
<label for="'.$key.'" class="'.implode(' ', $args['label_class']).'">'.$args['label'].'</label>
<select name="'.$key.'" id="'.$key.'" class="country_to_state '.implode(' ', $args['class']).'" rel="'.$args['rel'].'">
<option value="">'.__('Select a country&hellip;', 'woothemes').'</option>';
foreach($woocommerce->countries->get_allowed_countries() as $ckey=>$value) :
@ -322,7 +325,7 @@ class woocommerce_checkout {
case "state" :
$field = '<p class="form-row '.implode(' ', $args['class']).'">
<label for="'.$key.'" class="'.implode(' ', $args['label_class']).'">'.$args['label'].$required.'</label>';
<label for="'.$key.'" class="'.implode(' ', $args['label_class']).'">'.$args['label'].'</label>';
$current_cc = $this->get_value($args['rel']);
if (!$current_cc) $current_cc = $woocommerce->customer->get_country();
@ -350,7 +353,7 @@ class woocommerce_checkout {
case "textarea" :
$field = '<p class="form-row '.implode(' ', $args['class']).'">
<label for="'.$key.'" class="'.implode(' ', $args['label_class']).'">'.$args['label'].$required.'</label>
<label for="'.$key.'" class="'.implode(' ', $args['label_class']).'">'.$args['label'].'</label>
<textarea name="'.$key.'" class="input-text" id="'.$key.'" placeholder="'.$args['placeholder'].'" cols="5" rows="2">'. esc_textarea( $this->get_value( $key ) ).'</textarea>
</p>'.$after;
@ -359,14 +362,14 @@ class woocommerce_checkout {
$field = '<p class="form-row '.implode(' ', $args['class']).'">
<input type="'.$args['type'].'" class="input-checkbox" name="'.$key.'" id="'.$key.'" value="1" '.checked($this->get_value( $key ), 1, false).' />
<label for="'.$key.'" class="checkbox '.implode(' ', $args['label_class']).'">'.$args['label'].$required.'</label>
<label for="'.$key.'" class="checkbox '.implode(' ', $args['label_class']).'">'.$args['label'].'</label>
</p>'.$after;
break;
default :
$field = '<p class="form-row '.implode(' ', $args['class']).'">
<label for="'.$key.'" class="'.implode(' ', $args['label_class']).'">'.$args['label'].$required.'</label>
<label for="'.$key.'" class="'.implode(' ', $args['label_class']).'">'.$args['label'].'</label>
<input type="text" class="input-text" name="'.$key.'" id="'.$key.'" placeholder="'.$args['placeholder'].'" value="'. $this->get_value( $key ).'" />
</p>'.$after;
@ -887,7 +890,7 @@ class woocommerce_checkout {
if (isset( $this->posted[$input] ) && !empty($this->posted[$input])) :
return $this->posted[$input];
elseif (is_user_logged_in()) :
if (get_user_meta( get_current_user_id(), $input, true )) return get_user_meta( get_current_user_id(), $input, true );
if ($meta = get_user_meta( get_current_user_id(), $input, true )) return $meta;
$current_user = wp_get_current_user();

View File

@ -279,6 +279,7 @@ class woocommerce_countries {
'VIC' => __('Victoria', 'woothemes') ,
'WA' => __('Western Australia', 'woothemes')
),
'AT' => array(),
'BR' => array(
'AM' => __('Amazonas', 'woothemes'),
'AC' => __('Acre', 'woothemes'),
@ -324,7 +325,9 @@ class woocommerce_countries {
'SK' => __('Saskatchewan', 'woothemes') ,
'YT' => __('Yukon Territory', 'woothemes')
),
'CZ' => array(),
'DE' => array(),
'DK' => array(),
'US' => array(
'AL' => __('Alabama', 'woothemes') ,
'AK' => __('Alaska', 'woothemes') ,

View File

@ -2,7 +2,7 @@
/**
* WooCommerce Localisation
*
* Contains country-specific rules
* Contains country-specific rules. Spotted an error? Tell us on GitHub.
*
* @class woocommerce_localisation
* @package WooCommerce
@ -11,46 +11,159 @@
*/
class woocommerce_localisation {
var $locales;
var $default_locale;
var $locale;
/**
* Constructor
*/
function __construct() {
$this->locales => array(
$this->default_locale = array(
'required_fields' => array(
'first_name', 'last_name', 'address_1', 'city', 'postcode', 'country', 'state', 'email', 'phone'
),
'address_format' => "{name}\n{company}\n{address_1}\n{address_2}\n{city}\n{state}\n{postcode}\n{country}"
);
'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
),
)
)
);
$this->locale = array(
// Austrialia
'AU' => array(
'labels' => array(
'city' => __('Town/City', 'woothemes')
),
'address_format' => "{name}\n{company}\n{address_1}\n{address_2}\n{city} {state} {postcode}\n{country}"
),
// Austria
'AT' => array(
'field_postition' => array(
'city' => 7,
'postcode' => 6
),
'field_classes' => array(
'city' => array('form-row-last'),
'postcode' => array('form-row-first update_totals_on_change')
),
'required_fields' => array(
'first_name', 'last_name', 'address_1', 'city', 'postcode', 'country', 'email', 'phone'
),
'address_format' => "{name}\n{company}\n{address_1}\n{address_2}\n{postcode} {city}\n{country}"
),
// Canada
'CA' => array(
'labels' => array(
'state' => __('Province', 'woothemes')
)
),
// Chile
'CL' => array(
'labels' => array(
'state' => __('Municipality', 'woothemes')
),
'required_fields' => array(
'first_name', 'last_name', 'address_1', 'country', 'state', 'email', 'phone'
)
),
// China
'CN' => array(
'labels' => array(
'state' => __('Province', 'woothemes')
),
'address_format' => "{country} {postcode}\n{state}, {city}, {address_2}, {address_1}\n{company}\n{name}",
),
// Czech Republic
'CZ' => array(
'labels' => array(
'city' => __('Town', 'woothemes')
),
'address_format' => "{company}\n{name}\n{address_1}\n{address_2}\n{postcode} {city}\n{country}"
),
// Germany
'DE' => array(
'field_postition' => array(
'city' => 7,
'postcode' => 6
),
'field_classes' => array(
'city' => array('form-row-last'),
'postcode' => array('form-row-first update_totals_on_change')
),
'required_fields' => array(
'first_name', 'last_name', 'address_1', 'city', 'postcode', 'country', 'email', 'phone'
),
'address_format' => "{name}\n{company}\n{address_1}\n{address_2}\n{postcode} {city}\n{country}"
),
// Denmark
'DK' => array(
'labels' => array(
'city' => __('Town', 'woothemes')
),
'address_format' => "{company}\n{name}\n{address_1}\n{address_2}\n{postcode} {city}\n{country}"
),
// Germany
'GB' => array(
'field_postition' => array(
'city' => 7,
'postcode' => 6
),
'field_classes' => array(
'city' => array('form-row-last'),
'postcode' => array('form-row-first update_totals_on_change')
),
'required_fields' => array(
'first_name', 'last_name', 'address_1', 'city', 'postcode', 'country', 'email', 'phone'
),
'address_format' => "{name}\n{company}\n{address_1}\n{address_2}\n{postcode} {city}\n{country}"
),
);
// Actions
add_filter('woocommerce_billing_fields', array(&$this, 'apply_locale'), 0);
}
function apply_locale( $fields, $type = "billing_" ) {
global $woocommerce;
$country = $woocommerce->customer->get_country();
if (isset($this->locale[$country])) :
$locale = $this->locale[$country];
if (isset($locale['field_postition'])) :
foreach ($locale['field_postition'] as $field => $value) :
$fields[$type . $field]['position'] = $value;
endforeach;
endif;
if (isset($locale['field_classes'])) :
foreach ($locale['field_classes'] as $field => $value) :
$fields[$type . $field]['class'] = $value;
endforeach;
endif;
endif;
return $fields;
}
}

View File

@ -758,7 +758,9 @@ class woocommerce {
*/
function init_styles() {
$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
$chosen_en = (get_option('woocommerce_enable_chosen')=='yes') ? true : false;
$lightbox_en = (get_option('woocommerce_enable_lightbox')=='yes') ? true : false;
// Optional front end css
if ((defined('WOOCOMMERCE_USE_CSS') && WOOCOMMERCE_USE_CSS) || (!defined('WOOCOMMERCE_USE_CSS') && get_option('woocommerce_frontend_css')=='yes')) :
$css = file_exists(get_stylesheet_directory() . '/woocommerce/style.css') ? get_stylesheet_directory_uri() . '/woocommerce/style.css' : $this->plugin_url() . '/assets/css/woocommerce.css';
@ -766,7 +768,8 @@ class woocommerce {
wp_enqueue_style( 'woocommerce_frontend_styles' );
endif;
if (get_option('woocommerce_enable_lightbox')=='yes') wp_enqueue_style( 'woocommerce_fancybox_styles', $this->plugin_url() . '/assets/css/fancybox'.$suffix.'.css' );
if ($lightbox_en) wp_enqueue_style( 'woocommerce_fancybox_styles', $this->plugin_url() . '/assets/css/fancybox'.$suffix.'.css' );
if ($chosen_en) wp_enqueue_style( 'woocommerce_chosen_styles', $this->plugin_url() . '/assets/css/chosen'.$suffix.'.css' );
}
/**
@ -775,6 +778,7 @@ class woocommerce {
function frontend_scripts() {
$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
$lightbox_en = (get_option('woocommerce_enable_lightbox')=='yes') ? true : false;
$chosen_en = (get_option('woocommerce_enable_chosen')=='yes') ? true : false;
$jquery_ui_en = (get_option('woocommerce_enable_jquery_ui')=='yes') ? true : false;
$scripts_position = (get_option('woocommerce_scripts_position') == 'yes') ? true : false;
@ -790,6 +794,11 @@ class woocommerce {
wp_enqueue_script( 'fancybox' );
endif;
if ($chosen_en && is_checkout()) :
wp_register_script( 'chosen', $this->plugin_url() . '/assets/js/chosen.jquery'.$suffix.'.js', array('jquery'), '1.0' );
wp_enqueue_script( 'chosen' );
endif;
if ($jquery_ui_en) :
wp_register_script( 'jqueryui', $this->plugin_url() . '/assets/js/jquery-ui'.$suffix.'.js', 'jquery', '1.0', $scripts_position );
wp_register_script( 'wc_price_slider', $this->plugin_url() . '/assets/js/price_slider'.$suffix.'.js', 'jqueryui', '1.0', $scripts_position );
@ -813,7 +822,7 @@ class woocommerce {
$woocommerce_params = array(
'countries' => $states,
'select_state_text' => __('Select a state&hellip;', 'woothemes'),
'select_state_text' => __('Select an option&hellip;', 'woothemes'),
'state_text' => __('state', 'woothemes'),
'plugin_url' => $this->plugin_url(),
'ajax_url' => (!is_ssl()) ? str_replace('https', 'http', admin_url('admin-ajax.php')) : admin_url('admin-ajax.php'),