WOOCOMMERCE BỎ BỚT MỘT SỐ FIELD KHÔNG CẦN THIẾT KHI THANH TOÁN

5/5 - (1 bình chọn)
Để xóa bớt một field trong phần thanh toán, bạn chèn code này vào file functions.php của thư mục theme bạn đang dùng.
Đó là đoạn code mẫu nếu như bạn muốn xóa field nhập Post Code khi thanh toán. Nếu bạn muốn xóa thêm một field khác chỉ cần viết thêm một đoạn unset () nữa là được. Ví dụ
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
    unset($fields['billing']['billing_postcode']);
    unset($fields['billing']['billing_state']);
    unset($fields['billing']['billing_address_2']);
	unset($fields['billing']['billing_company']);
	unset($fields['billing']['billing_last_name']);
	unset($fields['billing']['billing_city']);
	unset($fields['billing']['billing_country']);
	unset($fields['order']['order_comments']);
     return $fields;
}

Cách làm placeholder các dòng input

woocommerce bo bot mot so field khong can thiet khi thanh toan 78614
function custom_woocommerce_checkout_fields( $fields ) {
$fields['billing']['billing_first_name']['placeholder'] = 'Họ tên';
$fields['billing']['billing_address_1']['placeholder'] = 'Địa chỉ';
$fields['billing']['billing_phone']['placeholder'] = 'Điện thoại';
$fields['billing']['billing_email']['placeholder'] = 'Email';
return $fields;
}
Vậy nếu bạn cần xóa thêm bất cứ field nào mà trong bài này mình không đề cập thì sao? Trước tiên bạn hãy quan sát một dòng unset() của mình như sau
unset($fields['billing']['billing_address_2']);
Bạn thấy giá trị billing và billing_address_2 chứ? Bây giờ bằng cách dựa vào danh sách các giá trị dưới đây, bạn có thể thay bằng một giá trị tương ứng với field bạn cần xóa
  • billing
    • billing_first_name
    • billing_last_name
    • billing_company
    • billing_address_1
    • billing_address_2
    • billing_city
    • billing_postcode
    • billing_country
    • billing_state
    • billing_email
    • billing_phone
  • shipping
    • shipping_first_name
    • shipping_last_name
    • shipping_company
    • shipping_address_1
    • shipping_address_2
    • shipping_city
    • shipping_postcode
    • shipping_country
    • shipping_state
  • account
    • account_username
    • account_password
    • account_password-2
  • order
    • order_comments
5/5 - (1 bình chọn)


  1. whoah this weblog is great i love studying your posts.
    Stay up the good work! You already know, many individuals
    are searching round for this info, you can help them greatly.

  2. Wonderful website. Plenty of helpful info here. I am sending
    it to a few friends ans additionally sharing in delicious.
    And of course, thanks on your sweat!

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *