Shipping calculator - Made state/postcode respect country locale like checkout.
Fixes #7637
This commit is contained in:
parent
9f269f765d
commit
66e6366be0
|
@ -546,11 +546,10 @@ class WC_Countries {
|
||||||
$locale_fields = array (
|
$locale_fields = array (
|
||||||
'address_1' => '#billing_address_1_field, #shipping_address_1_field',
|
'address_1' => '#billing_address_1_field, #shipping_address_1_field',
|
||||||
'address_2' => '#billing_address_2_field, #shipping_address_2_field',
|
'address_2' => '#billing_address_2_field, #shipping_address_2_field',
|
||||||
'state' => '#billing_state_field, #shipping_state_field',
|
'state' => '#billing_state_field, #shipping_state_field, #calc_shipping_state_field',
|
||||||
'postcode' => '#billing_postcode_field, #shipping_postcode_field',
|
'postcode' => '#billing_postcode_field, #shipping_postcode_field, #calc_shipping_postcode_field',
|
||||||
'city' => '#billing_city_field, #shipping_city_field'
|
'city' => '#billing_city_field, #shipping_city_field, #calc_shipping_city_field',
|
||||||
);
|
);
|
||||||
|
|
||||||
return apply_filters( 'woocommerce_country_locale_field_selectors', $locale_fields );
|
return apply_filters( 'woocommerce_country_locale_field_selectors', $locale_fields );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -583,12 +582,15 @@ class WC_Countries {
|
||||||
'AU' => array(
|
'AU' => array(
|
||||||
'city' => array(
|
'city' => array(
|
||||||
'label' => __( 'Suburb', 'woocommerce' ),
|
'label' => __( 'Suburb', 'woocommerce' ),
|
||||||
|
'placeholder' => __( 'Suburb', 'woocommerce' ),
|
||||||
),
|
),
|
||||||
'postcode' => array(
|
'postcode' => array(
|
||||||
'label' => __( 'Postcode', 'woocommerce' ),
|
'label' => __( 'Postcode', 'woocommerce' ),
|
||||||
|
'placeholder' => __( 'Postcode', 'woocommerce' ),
|
||||||
),
|
),
|
||||||
'state' => array(
|
'state' => array(
|
||||||
'label' => __( 'State', 'woocommerce' ),
|
'label' => __( 'State', 'woocommerce' ),
|
||||||
|
'placeholder' => __( 'State', 'woocommerce' ),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'BD' => array(
|
'BD' => array(
|
||||||
|
@ -597,6 +599,7 @@ class WC_Countries {
|
||||||
),
|
),
|
||||||
'state' => array(
|
'state' => array(
|
||||||
'label' => __( 'District', 'woocommerce' ),
|
'label' => __( 'District', 'woocommerce' ),
|
||||||
|
'placeholder' => __( 'District', 'woocommerce' ),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'BE' => array(
|
'BE' => array(
|
||||||
|
@ -604,6 +607,7 @@ class WC_Countries {
|
||||||
'state' => array(
|
'state' => array(
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'label' => __( 'Province', 'woocommerce' ),
|
'label' => __( 'Province', 'woocommerce' ),
|
||||||
|
'placeholder' => __( 'Province', 'woocommerce' ),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'BI' => array(
|
'BI' => array(
|
||||||
|
@ -626,12 +630,14 @@ class WC_Countries {
|
||||||
'CA' => array(
|
'CA' => array(
|
||||||
'state' => array(
|
'state' => array(
|
||||||
'label' => __( 'Province', 'woocommerce' ),
|
'label' => __( 'Province', 'woocommerce' ),
|
||||||
|
'placeholder' => __( 'Province', 'woocommerce' ),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'CH' => array(
|
'CH' => array(
|
||||||
'postcode_before_city' => true,
|
'postcode_before_city' => true,
|
||||||
'state' => array(
|
'state' => array(
|
||||||
'label' => __( 'Canton', 'woocommerce' ),
|
'label' => __( 'Canton', 'woocommerce' ),
|
||||||
|
'placeholder' => __( 'Canton', 'woocommerce' ),
|
||||||
'required' => false
|
'required' => false
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
@ -644,12 +650,14 @@ class WC_Countries {
|
||||||
'hidden' => true
|
'hidden' => true
|
||||||
),
|
),
|
||||||
'state' => array(
|
'state' => array(
|
||||||
'label' => __( 'Region', 'woocommerce' )
|
'label' => __( 'Region', 'woocommerce' ),
|
||||||
|
'placeholder' => __( 'Region', 'woocommerce' )
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'CN' => array(
|
'CN' => array(
|
||||||
'state' => array(
|
'state' => array(
|
||||||
'label' => __( 'Province', 'woocommerce' ),
|
'label' => __( 'Province', 'woocommerce' ),
|
||||||
|
'placeholder' => __( 'Province', 'woocommerce' ),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'CO' => array(
|
'CO' => array(
|
||||||
|
@ -698,19 +706,23 @@ class WC_Countries {
|
||||||
),
|
),
|
||||||
'city' => array(
|
'city' => array(
|
||||||
'label' => __( 'Town / District', 'woocommerce' ),
|
'label' => __( 'Town / District', 'woocommerce' ),
|
||||||
|
'placeholder' => __( 'Town / District', 'woocommerce' )
|
||||||
),
|
),
|
||||||
'state' => array(
|
'state' => array(
|
||||||
'label' => __( 'Region', 'woocommerce' ),
|
'label' => __( 'Region', 'woocommerce' ),
|
||||||
|
'placeholder' => __( 'Region', 'woocommerce' ),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'HU' => array(
|
'HU' => array(
|
||||||
'state' => array(
|
'state' => array(
|
||||||
'label' => __( 'County', 'woocommerce' ),
|
'label' => __( 'County', 'woocommerce' ),
|
||||||
|
'placeholder' => __( 'County', 'woocommerce' ),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'ID' => array(
|
'ID' => array(
|
||||||
'state' => array(
|
'state' => array(
|
||||||
'label' => __( 'Province', 'woocommerce' ),
|
'label' => __( 'Province', 'woocommerce' ),
|
||||||
|
'placeholder' => __( 'Province', 'woocommerce' ),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'IS' => array(
|
'IS' => array(
|
||||||
|
@ -730,6 +742,7 @@ class WC_Countries {
|
||||||
'state' => array(
|
'state' => array(
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'label' => __( 'Province', 'woocommerce' ),
|
'label' => __( 'Province', 'woocommerce' ),
|
||||||
|
'placeholder' => __( 'Province', 'woocommerce' ),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'JP' => array(
|
'JP' => array(
|
||||||
|
@ -747,6 +760,7 @@ class WC_Countries {
|
||||||
'state' => array(
|
'state' => array(
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'label' => __( 'Province', 'woocommerce' ),
|
'label' => __( 'Province', 'woocommerce' ),
|
||||||
|
'placeholder' => __( 'Province', 'woocommerce' ),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'NZ' => array(
|
'NZ' => array(
|
||||||
|
@ -764,6 +778,7 @@ class WC_Countries {
|
||||||
'postcode_before_city' => true,
|
'postcode_before_city' => true,
|
||||||
'state' => array(
|
'state' => array(
|
||||||
'label' => __( 'District', 'woocommerce' ),
|
'label' => __( 'District', 'woocommerce' ),
|
||||||
|
'placeholder' => __( 'District', 'woocommerce' ),
|
||||||
),
|
),
|
||||||
'postcode' => array(
|
'postcode' => array(
|
||||||
'required' => false,
|
'required' => false,
|
||||||
|
@ -807,12 +822,14 @@ class WC_Countries {
|
||||||
'postcode_before_city' => true,
|
'postcode_before_city' => true,
|
||||||
'state' => array(
|
'state' => array(
|
||||||
'label' => __( 'Province', 'woocommerce' ),
|
'label' => __( 'Province', 'woocommerce' ),
|
||||||
|
'placeholder' => __( 'Province', 'woocommerce' ),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'LI' => array(
|
'LI' => array(
|
||||||
'postcode_before_city' => true,
|
'postcode_before_city' => true,
|
||||||
'state' => array(
|
'state' => array(
|
||||||
'label' => __( 'Municipality', 'woocommerce' ),
|
'label' => __( 'Municipality', 'woocommerce' ),
|
||||||
|
'placeholder' => __( 'Municipality', 'woocommerce' ),
|
||||||
'required' => false
|
'required' => false
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
@ -831,22 +848,27 @@ class WC_Countries {
|
||||||
'postcode_before_city' => true,
|
'postcode_before_city' => true,
|
||||||
'state' => array(
|
'state' => array(
|
||||||
'label' => __( 'Province', 'woocommerce' ),
|
'label' => __( 'Province', 'woocommerce' ),
|
||||||
|
'placeholder' => __( 'Province', 'woocommerce' ),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'US' => array(
|
'US' => array(
|
||||||
'postcode' => array(
|
'postcode' => array(
|
||||||
'label' => __( 'Zip', 'woocommerce' ),
|
'label' => __( 'Zip', 'woocommerce' ),
|
||||||
|
'placeholder' => __( 'Zip', 'woocommerce' ),
|
||||||
),
|
),
|
||||||
'state' => array(
|
'state' => array(
|
||||||
'label' => __( 'State', 'woocommerce' ),
|
'label' => __( 'State', 'woocommerce' ),
|
||||||
|
'placeholder' => __( 'State', 'woocommerce' ),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'GB' => array(
|
'GB' => array(
|
||||||
'postcode' => array(
|
'postcode' => array(
|
||||||
'label' => __( 'Postcode', 'woocommerce' ),
|
'label' => __( 'Postcode', 'woocommerce' ),
|
||||||
|
'placeholder' => __( 'Postcode', 'woocommerce' ),
|
||||||
),
|
),
|
||||||
'state' => array(
|
'state' => array(
|
||||||
'label' => __( 'County', 'woocommerce' ),
|
'label' => __( 'County', 'woocommerce' ),
|
||||||
|
'placeholder' => __( 'County', 'woocommerce' ),
|
||||||
'required' => false
|
'required' => false
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
@ -873,6 +895,7 @@ class WC_Countries {
|
||||||
'ZA' => array(
|
'ZA' => array(
|
||||||
'state' => array(
|
'state' => array(
|
||||||
'label' => __( 'Province', 'woocommerce' ),
|
'label' => __( 'Province', 'woocommerce' ),
|
||||||
|
'placeholder' => __( 'Province', 'woocommerce' ),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'ZW' => array(
|
'ZW' => array(
|
||||||
|
|
|
@ -132,7 +132,7 @@ class WC_Frontend_Scripts {
|
||||||
self::enqueue_script( 'wc-add-to-cart', $frontend_script_path . 'add-to-cart' . $suffix . '.js' );
|
self::enqueue_script( 'wc-add-to-cart', $frontend_script_path . 'add-to-cart' . $suffix . '.js' );
|
||||||
}
|
}
|
||||||
if ( is_cart() ) {
|
if ( is_cart() ) {
|
||||||
self::enqueue_script( 'wc-cart', $frontend_script_path . 'cart' . $suffix . '.js', array( 'jquery', 'wc-country-select' ) );
|
self::enqueue_script( 'wc-cart', $frontend_script_path . 'cart' . $suffix . '.js', array( 'jquery', 'wc-country-select', 'wc-address-i18n' ) );
|
||||||
}
|
}
|
||||||
if ( is_checkout() || is_page( get_option( 'woocommerce_myaccount_page_id' ) ) ) {
|
if ( is_checkout() || is_page( get_option( 'woocommerce_myaccount_page_id' ) ) ) {
|
||||||
self::enqueue_script( 'select2' );
|
self::enqueue_script( 'select2' );
|
||||||
|
|
|
@ -149,6 +149,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
|
||||||
* Tweak - Improve grouped product quantity inputs.
|
* Tweak - Improve grouped product quantity inputs.
|
||||||
* Tweak - Load the persistant cart if cart is empty.
|
* Tweak - Load the persistant cart if cart is empty.
|
||||||
* Tweak - Prevent cart being cleared when accessing the login page.
|
* Tweak - Prevent cart being cleared when accessing the login page.
|
||||||
|
* Tweak - Shipping calculator - Made state/postcode respect country locale like checkout.
|
||||||
|
|
||||||
= 2.3.5 - 20/02/2015 =
|
= 2.3.5 - 20/02/2015 =
|
||||||
* Fix - Plain text address formatting.
|
* Fix - Plain text address formatting.
|
||||||
|
|
|
@ -25,7 +25,7 @@ if ( get_option( 'woocommerce_enable_shipping_calc' ) === 'no' || ! WC()->cart->
|
||||||
|
|
||||||
<section class="shipping-calculator-form" style="display:none;">
|
<section class="shipping-calculator-form" style="display:none;">
|
||||||
|
|
||||||
<p class="form-row form-row-wide">
|
<p class="form-row form-row-wide" id="calc_shipping_country_field">
|
||||||
<select name="calc_shipping_country" id="calc_shipping_country" class="country_to_state" rel="calc_shipping_state">
|
<select name="calc_shipping_country" id="calc_shipping_country" class="country_to_state" rel="calc_shipping_state">
|
||||||
<option value=""><?php _e( 'Select a country…', 'woocommerce' ); ?></option>
|
<option value=""><?php _e( 'Select a country…', 'woocommerce' ); ?></option>
|
||||||
<?php
|
<?php
|
||||||
|
@ -35,7 +35,7 @@ if ( get_option( 'woocommerce_enable_shipping_calc' ) === 'no' || ! WC()->cart->
|
||||||
</select>
|
</select>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p class="form-row form-row-wide">
|
<p class="form-row form-row-wide" id="calc_shipping_state_field">
|
||||||
<?php
|
<?php
|
||||||
$current_cc = WC()->customer->get_shipping_country();
|
$current_cc = WC()->customer->get_shipping_country();
|
||||||
$current_r = WC()->customer->get_shipping_state();
|
$current_r = WC()->customer->get_shipping_state();
|
||||||
|
@ -70,7 +70,7 @@ if ( get_option( 'woocommerce_enable_shipping_calc' ) === 'no' || ! WC()->cart->
|
||||||
|
|
||||||
<?php if ( apply_filters( 'woocommerce_shipping_calculator_enable_city', false ) ) : ?>
|
<?php if ( apply_filters( 'woocommerce_shipping_calculator_enable_city', false ) ) : ?>
|
||||||
|
|
||||||
<p class="form-row form-row-wide">
|
<p class="form-row form-row-wide" id="calc_shipping_city_field">
|
||||||
<input type="text" class="input-text" value="<?php echo esc_attr( WC()->customer->get_shipping_city() ); ?>" placeholder="<?php _e( 'City', 'woocommerce' ); ?>" name="calc_shipping_city" id="calc_shipping_city" />
|
<input type="text" class="input-text" value="<?php echo esc_attr( WC()->customer->get_shipping_city() ); ?>" placeholder="<?php _e( 'City', 'woocommerce' ); ?>" name="calc_shipping_city" id="calc_shipping_city" />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ if ( get_option( 'woocommerce_enable_shipping_calc' ) === 'no' || ! WC()->cart->
|
||||||
|
|
||||||
<?php if ( apply_filters( 'woocommerce_shipping_calculator_enable_postcode', true ) ) : ?>
|
<?php if ( apply_filters( 'woocommerce_shipping_calculator_enable_postcode', true ) ) : ?>
|
||||||
|
|
||||||
<p class="form-row form-row-wide">
|
<p class="form-row form-row-wide" id="calc_shipping_postcode_field">
|
||||||
<input type="text" class="input-text" value="<?php echo esc_attr( WC()->customer->get_shipping_postcode() ); ?>" placeholder="<?php _e( 'Postcode / Zip', 'woocommerce' ); ?>" name="calc_shipping_postcode" id="calc_shipping_postcode" />
|
<input type="text" class="input-text" value="<?php echo esc_attr( WC()->customer->get_shipping_postcode() ); ?>" placeholder="<?php _e( 'Postcode / Zip', 'woocommerce' ); ?>" name="calc_shipping_postcode" id="calc_shipping_postcode" />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue