- lựa chọn quốc gia
- Họ tên
- Tên công ty
- Địa chỉ (2 dòng)
- Thành phố
- Mã Zip Code
- Số điện thoại
Remove Order Notes in Checkout Woocommerce |
/*Remove Custom Fields in Checkout Woocommerce*/
// Hook in
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[‘order’][‘order_comments’]);
return $fields;
}
unset($fields[‘billing’][‘billing_address_2’]);
unset($fields[‘shipping’][‘shipping_address_2’]);
/**
* Add the field to the checkout
**/
add_action(‘woocommerce_after_order_notes’, ‘my_custom_checkout_field’);
function my_custom_checkout_field( $checkout ) {
echo ‘<div id=”my_custom_checkout_field”><h3>’.__(‘Field Test’).'</h3>’;
woocommerce_form_field( ‘my_field_name’, array(
‘type’ => ‘text’,
‘class’ => array(‘my-field-class form-row-wide’),
‘label’ => __(‘Fill in this field’),
‘placeholder’ => __(‘Enter something’),
), $checkout->get_value( ‘my_field_name’ ));
echo ‘</div>’;
}
/**
* Process the checkout
**/
add_action(‘woocommerce_checkout_process’, ‘my_custom_checkout_field_process’);
function my_custom_checkout_field_process() {
global $woocommerce;
// Check if set, if its not set add an error.
if (!$_POST[‘my_field_name’])
$woocommerce->add_error( __(‘Please enter something into this new shiny field.’) );
}
/**
* Update the order meta with field value
**/
add_action(‘woocommerce_checkout_update_order_meta’, ‘my_custom_checkout_field_update_order_meta’);
function my_custom_checkout_field_update_order_meta( $order_id ) {
if ($_POST[‘my_field_name’]) update_post_meta( $order_id, ‘Field Test’, esc_attr($_POST[‘my_field_name’]));
}
Insert New Customs Fields in Checkout Woocommerce |
Như vậy, các bạn có thể tạo thêm bất kì phần nào để phục vụ cho việc bán hàng của mình chỉ với vài dòng code như trên. Những chỗ bạn cần thay là những chỗ in đậm dưới đây.
echo ‘<div id=”my_custom_checkout_field”><h3>’.__(‘Field Test‘).'</h3>’;
‘label’ => __(‘Fill in this field‘),
‘placeholder’ => __(‘Enter something‘),
if ($_POST[‘my_field_name’]) update_post_meta( $order_id, ‘Field Test‘, esc_attr($_POST[‘my_field_name’]));
Tìm trên Google
- Hướng dẫn thêm/xóa các fields trong trang Check-out của Woocommerce
- Remove/Insert Custom Fields in checkout woocommerce
- Thêm Custom Fields mới trong trang thanh toán Woocommerce
- Xóa bớt Custom Fields trong trang thanh toán Woocommerce
- Tùy biến trang thanh toán Woocommerce
- Tùy tiến trang checkout woocommerce
- Thiết kế website bằng WordPress dùng plugin Woocommerce
- How to create website wordpress using woocommerce
- Hướng dẫn xử lí lỗi Shockwave Flash has Crashed trên Google Chrome và Cốc Cốc
- Hướng dẫn Gửi/nhận mail domain thông qua tài khoản Gmail
- Hướng dẫn thiết kế Website bằng Bootstrap Responsive (Phần 2)
- Hướng dẫn hẹn giờ đăng bài tự động trên WordPress
- Hướng dẫn hiển thị tên tác giả bài viết trong WordPress lên facebook