Những đoạn code thường dùng để chỉnh sửa trang checkout Woocommerce
Dưới đây là những đoạn code thường hay dùng để chỉnh sửa cho trang checkout trong Woo .
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' ); // Our hooked in function - $fields is passed via the filter! function custom_override_checkout_fields( $fields ) { unset($fields['billing']['billing_company']); // unset($fields['billing']['billing_address_1']); unset($fields['billing']['billing_address_2']); unset($fields['billing']['billing_country']); unset($fields['billing']['billing_state']); unset($fields['billing']['billing_postcode']); unset($fields['billing']['billing_email']); return $fields; }
Phía trên đây là đoạn code để bỏ đi những trường không cần thiết trong trang checkout.
</pre> add_filter( 'woocommerce_billing_fields' , 'ced_remove_billing_fields' ); function ced_remove_billing_fields( $fields ) { unset($fields['billing_last_name']); return $fields; } add_filter( 'woocommerce_checkout_fields' , 'ced_rename_checkout_fields' ); // Change placeholder and label text function ced_rename_checkout_fields( $fields ) { $fields['billing']['billing_first_name']['placeholder'] = 'Họ và tên'; $fields['billing']['billing_first_name']['label'] = 'Họ và Tên'; return $fields; }
Đây là đoạn code bỏ đi trường last name và đổi trường firts name thành họ và tên