CHƯƠNG TRÌNH GIẢM 50% GIÁ TẤT CẢ CÁC GÓI HOSTING WORDPRESS => Link giảm 50%
Nếu bạn đang cần Code nâng cao các chức năng của WooCommerce liên quan đến thêm các trường quản lý dữ liệu Sản Phẩm. Rất may là WooCommerce đã hỗ trợ cho chúng ta đầy đủ trọn bộ Field. Bạn chỉ cần rê chuột vào vùng code bên dưới, copy và sử dụng rất dễ dàng.

🌱 Nếu thấy bài viết hữu ích, bạn có thể ủng hộ tác giả bằng cách nhấn vào quảng cáo bên dưới — như một donate miễn phí. Bạn không mất gì nhưng chúng tôi sẽ có thêm chi phí để duy trì và vận hành website. Cảm ơn bạn! 🙏
Hướng dẫn tạo Product Data Tabs trong WooCommerce – WordPress Tutorial
1. WooCommerce text input box
//text input box
woocommerce_wp_text_input(
array(
'id' => 'wpshare247_wooc_text_input',
'value' => get_post_meta( get_the_ID(), 'wpshare247_wooc_text_input', true ),
'label' => __( 'Trường Text Box', 'woocommerce' ),
'placeholder' => __( 'Nhập giá trị placeholder', 'woocommerce' ),
'class' => 'wpshare247-c1 wpshare247-c2',
'style' => 'color:red;',
'wrapper_class' => 'wpshare247-wrapper-c1 wpshare247-wrapper-c2',
'type' => 'text',
'description' => __( 'Mô tả Trường Text Box', 'woocommerce' ),
'desc_tip' => true,
'data_type' => '' // '', price, decimal, stock, url
)
);
2. WooCommerce textarea input box
//textarea input box
woocommerce_wp_textarea_input(
array(
'id' => 'wpshare247_wooc_textarea_input',
'value' => get_post_meta( get_the_ID(), 'wpshare247_wooc_textarea_input', true ),
'label' => __( 'Trường textarea', 'woocommerce' ),
'placeholder' => __( 'Nhập giá trị placeholder', 'woocommerce' ),
'class' => 'wpshare247-c1 wpshare247-c2',
'style' => 'color:red;',
'wrapper_class' => 'wpshare247-wrapper-c1 wpshare247-wrapper-c2',
'description' => __( 'Mô tả Trường textarea', 'woocommerce' ),
'desc_tip' => true,
'rows' => 5,
'cols' => 50,
)
);
3. WooCommerce checkbox input box
//checkbox input box
woocommerce_wp_checkbox(
array(
'id' => 'wpshare247_wooc_checkbox_input',
'value' => get_post_meta( get_the_ID(), 'wpshare247_wooc_checkbox_input', true ),
'label' => __( 'Trường checkbox', 'woocommerce' ),
'class' => 'wpshare247-c1 wpshare247-c2',
'style' => 'color:red;',
'wrapper_class' => 'wpshare247-wrapper-c1 wpshare247-wrapper-c2',
'cbvalue' => 'yes',
'description' => __( 'Mô tả Trường checkbox', 'woocommerce' ),
'desc_tip' => true
)
);
4. WooCommerce select input box
//select input box
woocommerce_wp_select(
array(
'id' => 'wpshare247_wooc_select_input',
'value' => get_post_meta( get_the_ID(), 'wpshare247_wooc_select_input', true ),
'options' => array('1' => 'Giá trị 1', '2' => 'Giá trị 2'),
'label' => __( 'Trường select', 'woocommerce' ),
'class' => 'wpshare247-c1 wpshare247-c2',
'style' => 'color:red;',
'wrapper_class' => 'wpshare247-wrapper-c1 wpshare247-wrapper-c2',
'description' => __( 'Mô tả Trường select', 'woocommerce' ),
'desc_tip' => true
)
);
5. WooCommerce radio input box
//radio input box
woocommerce_wp_radio(
array(
'id' => 'wpshare247_wooc_radio_input',
'value' => get_post_meta( get_the_ID(), 'wpshare247_wooc_radio_input', true ),
'options' => array('1' => 'Giá trị 1', '2' => 'Giá trị 2'),
'label' => __( '', 'woocommerce' ),
'class' => 'wpshare247-c1 wpshare247-c2',
'style' => 'color:red;',
'wrapper_class' => 'wpshare247-wrapper-c1 wpshare247-wrapper-c2',
'description' => __( 'Mô tả Trường radio', 'woocommerce' ),
'desc_tip' => true
)
);
Các trường bên trên có thể dễ dàng sử dụng trong trường hợp chúng ta thêm các Product Data vào Tab Sản Phẩm hoặc khi bạn cần thêm vào mục Setting quản lí của WooCommerce.

CHƯƠNG TRÌNH GIẢM 50% GIÁ TẤT CẢ CÁC GÓI HOSTING WORDPRESS => Link giảm 50%