Để 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
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
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?
Your point of view caught my eye and was very interesting. Thanks. I have a question for you.
I think every concept you put up in your post is strong and will undoubtedly be implemented. Still, the posts are too brief for inexperienced readers. Would you kindly extend them a little bit from now on? I appreciate the post.
Somebody essentially lend a hand to make significantly posts I might state That is the very first time I frequented your web page and up to now I surprised with the research you made to create this particular put up amazing Excellent job
I liked it as much as you did. Even though the picture and writing are good, you’re looking forward to what comes next. If you defend this walk, it will be pretty much the same every time.