mirror of
https://github.com/10h30/woo-viet.git
synced 2026-06-05 15:09:49 +09:00
Issue #17 - Arrange the address fields to the Vietnam standard: Country - Province - District - Address
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
.woocommerce-billing-fields__field-wrapper.active {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
#billing_first_name_field {
|
||||
order: 1;
|
||||
}
|
||||
|
||||
#billing_last_name_field {
|
||||
order: 2;
|
||||
}
|
||||
|
||||
#billing_company_field {
|
||||
order: 3;
|
||||
}
|
||||
|
||||
#billing_country_field {
|
||||
order: 4;
|
||||
}
|
||||
|
||||
#billing_state_field {
|
||||
order: 5;
|
||||
}
|
||||
|
||||
#billing_city_field {
|
||||
order: 6;
|
||||
}
|
||||
|
||||
#billing_address_1_field {
|
||||
order: 7;
|
||||
}
|
||||
|
||||
#billing_address_2_field {
|
||||
order: 8;
|
||||
}
|
||||
|
||||
#billing_postcode_field {
|
||||
order: 9;
|
||||
}
|
||||
|
||||
#billing_phone_field {
|
||||
order: 10;
|
||||
}
|
||||
|
||||
#billing_email_field {
|
||||
order: 11;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
(function($) {
|
||||
$('#billing_country_field').on('change', function() {
|
||||
|
||||
// Get country code
|
||||
var country_code = $(this).find('#billing_country').val();
|
||||
|
||||
// Match country code with Vietnam
|
||||
if(country_code == 'VN') {
|
||||
$('.woocommerce-billing-fields__field-wrapper').addClass('active');
|
||||
} else {
|
||||
$('.woocommerce-billing-fields__field-wrapper').removeClass('active');
|
||||
}
|
||||
})
|
||||
})(jQuery)
|
||||
@@ -21,6 +21,9 @@ class WooViet_Provinces {
|
||||
add_filter( 'woocommerce_states', array( $this, 'add_provinces' ) );
|
||||
add_filter( 'woocommerce_get_country_locale', array( $this, 'edit_vn_locale' ) );
|
||||
add_filter( 'woocommerce_localisation_address_formats', array( $this, 'edit_vn_address_formats' ) );
|
||||
|
||||
// Enqueue province scripts
|
||||
add_action( 'wp_enqueue_scripts', array( $this, 'load_provinces_scripts' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,4 +139,18 @@ class WooViet_Provinces {
|
||||
return $states;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue provinces scripts
|
||||
*
|
||||
* @author Longkt
|
||||
* @since 1.4
|
||||
*/
|
||||
public function load_provinces_scripts() {
|
||||
// Enqueue province style
|
||||
wp_enqueue_style( 'woo-viet-provinces-style', WOO_VIET_URL . 'assets/provinces.css' );
|
||||
|
||||
// Enqueue province script
|
||||
wp_enqueue_script( 'woo-viet-provinces-script', WOO_VIET_URL . 'assets/provinces.js', array( 'jquery' ), '1.0', true );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user