Chỉnh sửa woocommerce countries, states, continents (ok)
wp-content\themes\astra-child\functions.php
add_filter('woocommerce_countries', 'custom_us_countries', 10, 1);
function custom_us_countries($countries) {
$countries = [
"VN" => "Việt Nam",
"ND" => "Nam Định",
"HN" => "Hà Nội",
];
return $countries;
}
add_filter('woocommerce_states', 'custom_us_states', 10, 1);
function custom_us_states($states) {
$states = [
'ND' => [ // Nam Định states.
'ND-01' => __('ND1', 'woocommerce'),
'ND-02' => __('ND2', 'woocommerce'),
'ND-03' => __('ND3', 'woocommerce'),
'ND-04' => __('ND4', 'woocommerce'),
'ND-05' => __('ND5', 'woocommerce'),
'ND-06' => __('ND6', 'woocommerce'),
],
'HN' => [ // Hà Nội states.
'HN-01' => __('HN1', 'woocommerce'),
'HN-02' => __('HN2', 'woocommerce'),
'HN-03' => __('HN3', 'woocommerce'),
'HN-04' => __('HN4', 'woocommerce'),
'HN-05' => __('HN5', 'woocommerce'),
'HN-06' => __('HN6', 'woocommerce'),
],
];
$states['VN'] = array_merge($states['ND'], $states['HN']);
return $states;
}
add_filter('woocommerce_continents', 'custom_us_continents', 10, 1);
function custom_us_continents($continents) {
$continents = [
'AS' => [
'name' => __( 'Việt Nam', 'woocommerce' ),
'countries' => array(
'ND',
'HN'
),
]
];
return $continents;
}
add_filter( 'woocommerce_countries_base_country', 'wp_kama_woocommerce_customer_country', 10, 1 );
function wp_kama_woocommerce_customer_country($country) {
$country = "ND";
return $country;
}




query GetCountryStates {
wooStates(countryCode: "ND") {
states {
stateCode
stateName
}
}
}
{
"data": {
"wooStates": {
"states": [
{
"stateCode": "ND-01",
"stateName": "ND1"
},
{
"stateCode": "ND-09",
"stateName": "ND2"
},
{
"stateCode": "ND-02",
"stateName": "ND3"
},
{
"stateCode": "ND-03",
"stateName": "ND4"
},
{
"stateCode": "ND-04",
"stateName": "ND5"
},
{
"stateCode": "ND-05",
"stateName": "ND6"
}
]
}
}
}
Previous[ERROR] dùng hàm error_log("aaaaaaaa1"); để ghi lỗi vào fileNext[ERROR] The field \"RootMutation.login\" cannot be accessed without authentication. (ok)
Last updated
Was this helpful?