mengganti nama label
Updated on September 30, 2020 in Plugin Ongkos Kirim
Premium  6 on September 29, 2020

setelah mengaktifkan plugin ongkos kirim
label city saya jadi terganti oleh plugin

apakah saya bisa mengubah label city menggunakan add filter pada function theme?

menggunakan translate bahasa indonesia pada build in wordpress untuk seluruh sistem shopping cart tidak sesuai kebutuhan saya.
saya prefer mengubah label melalui filter

terima kasih

  • Liked by
By using the forum you are agree with tonjoo studio license agreement
Moderator 0 on September 29, 2020

Halo,

Anda bisa menggunakan hook-hook berikut.


  • `woocommerce_checkout_fields`

  • `woocommerce_billing_fields`

  • `woocommerce_shipping_fields` dengan priority diatas 40

Salam,
Tonjoostudio support

  • Liked by
Cancel
By using the forum you are agree with tonjoo studio license agreement
Message :
Premium  0 on September 29, 2020

function custom_woo_checkout_fields( $fields ) {

$fields[‘shipping’][‘shipping_state’] = array(
‘label’ => ‘Provinsi Penerima’,
‘priority’ => 12,
‘required’ => true,
‘class’ => array(‘form-row-wide’)
);

return $fields;
}

add_filter( ‘woocommerce_checkout_fields’ , ‘custom_woo_checkout_fields’, 50 );

menggunakan script diatas, display pada browser tetap label versi Tonjoo yakni "Province"

tetapi kalau saya view source, labelnya "Provinsi Penerima" pada source di browser

sepertinya otomatis direplace oleh

<script type=’text/javascript’ id=’wc-address-i18n-js-extra’>

  • Liked by
Cancel
By using the forum you are agree with tonjoo studio license agreement
Message :
Moderator 0 on September 29, 2020

Halo,

Silahkan coba dengan hook berikut.

add_filter( ‘woocommerce_get_country_locale’, ‘custom_label’, 30 );
function custom_label( $fields ) {
$fields[‘ID’][‘state’][‘label’] = ‘Provinsi Penerima’;
return $fields;
}

Salam,
Tonjoostudio support

  • Liked by
Cancel
By using the forum you are agree with tonjoo studio license agreement
Message :
Premium  0 on September 29, 2020

function custom_label( $fields ) {
$fields[‘ID’][‘state’][‘label’] = "Provinsi Penerima";
$fields[‘ID’][‘city’][‘label’] = "Kota Penerima";
$fields[‘ID’][‘district’][‘label’] = "Kecamatan Penerima";
return $fields;
}
add_filter( ‘woocommerce_get_country_locale’, ‘custom_label’, 30 );

yang state dan city bisa muncul sesuai
tetapi district masih menggunakan label "District"

  • Liked by
Cancel
By using the forum you are agree with tonjoo studio license agreement
Message :
Premium  0 on September 29, 2020

maaf satu pertanyaan lagi
bagaimana caranya saya disable billing_district?

saya mencoba

unset($fields[‘billing’][‘billing_district’]);

Billing district memang hilang dari halaman checkout
tetapi tetap muncul error "Billing district required" saat proses checkout

terima kasih

  • Liked by
Cancel
By using the forum you are agree with tonjoo studio license agreement
Message :
Moderator 0 on September 30, 2020

Halo,

Mungkin Anda bisa mencoba 2 metode berikut

// method 1.
add_filter( ‘woocommerce_checkout_fields’, function( $fields ) {
$fields[‘billing’][‘billing_state’][‘label’] = ‘Provinsi’;
$fields[‘billing’][‘billing_city’][‘label’] = ‘Kabupaten’;
$fields[‘billing’][‘billing_district’][‘label’] = ‘Kecamatan’;
$fields[‘shipping’][‘shipping_state’][‘label’] = ‘Provinsi’;
$fields[‘shipping’][‘shipping_city’][‘label’] = ‘Kabupaten’;
$fields[‘shipping’][‘shipping_district’][‘label’] = ‘Kecamatan’;
return $fields;
}, 99 );

// method 2.
add_filter( ‘woocommerce_billing_fields’, function( $fields ) {
$fields[‘billing_state’][‘label’] = ‘Provinsi’;
$fields[‘billing_city’][‘label’] = ‘Kabupaten’;
$fields[‘billing_district’][‘label’] = ‘Kecamatan’;
return $fields;
}, 99 );
add_filter( ‘woocommerce_shipping_fields’, function( $fields ) {
$fields[‘shipping_state’][‘label’] = ‘Provinsi’;
$fields[‘shipping_city’][‘label’] = ‘Kabupaten’;
$fields[‘shipping_district’][‘label’] = ‘Kecamatan’;
return $fields;
}, 99 );

Billing district tidak bisa dihilangkan karena field ini dibutuhkan untuk perhitungan ongkos kirim.

  • Liked by
Cancel
By using the forum you are agree with tonjoo studio license agreement
Message :
Loading more replies
You are not logged in

Please login here or simply sign up here .