Improve order checkout page #17 (#43)

Issue #17 - Arrange the address fields to the Vietnam standard: Country - Province - District - Address
This commit is contained in:
longnguyen
2018-04-16 21:59:23 +07:00
committed by Dat Hoang
parent 1ad14ee9b8
commit cf7bf361c1
3 changed files with 79 additions and 0 deletions
+48
View File
@@ -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;
}
+14
View File
@@ -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)
+17
View File
@@ -21,6 +21,9 @@ class WooViet_Provinces {
add_filter( 'woocommerce_states', array( $this, 'add_provinces' ) ); add_filter( 'woocommerce_states', array( $this, 'add_provinces' ) );
add_filter( 'woocommerce_get_country_locale', array( $this, 'edit_vn_locale' ) ); add_filter( 'woocommerce_get_country_locale', array( $this, 'edit_vn_locale' ) );
add_filter( 'woocommerce_localisation_address_formats', array( $this, 'edit_vn_address_formats' ) ); 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; 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 );
}
} }