ĐĂNG TIN
logo
Online:
Visits: 1,685,749,294
Stories: 8,383,743
Profile image
0
0
Tác giả: fcwordpress
Trang tin cá nhân | Bài đã đăng
Lượt xem

Hiện tại:
1h trước: 1
24h trước: 1
Tổng số: 57
Hướng dẫn custom woocommerce phần 6
Sunday, July 24, 2016 2:15
% of readers think this story is Fact. Add your two cents.


Nội dung:  trong phần này chúng ta sẽ tìm hiểu, thêm một field mới vào quản trị woocoommerce, show field mới ra dưới short description

Mời bạn xem video: 

Tóm tắt video:

  • Code add new field vào thẻ general woocommerce
// Display Fields add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' ); // Save Fields add_action( 'woocommerce_process_product_meta', 'woo_add_custom_general_fields_save' ); function woo_add_custom_general_fields() { global $woocommerce, $post; echo '
'; // Text Field woocommerce_wp_text_input( array( 'id' => '_khuyen_mai', 'label' => __( 'Khuyến mãi', 'woocommerce' ), 'placeholder' => 'Thông tin khuyến mãi', 'desc_tip' => 'true', 'description' => __( '', 'woocommerce' ) ) ); // Textarea woocommerce_wp_textarea_input( array( 'id' => '_thi_truong_phuc_vu', 'label' => __( 'Thị trường phục vụ', 'woocommerce' ), 'placeholder' => '', 'description' => __( '', 'woocommerce' ) ) ); echo '
'; } function woo_add_custom_general_fields_save( $post_id ){ // Text Field $woocommerce_text_field = $_POST['_khuyen_mai']; if( !empty( $woocommerce_text_field ) ) update_post_meta( $post_id, '_khuyen_mai', esc_attr( $woocommerce_text_field ) ); // Textarea $woocommerce_textarea = $_POST['_thi_truong_phuc_vu']; if( !empty( $woocommerce_textarea ) ) update_post_meta( $post_id, '_thi_truong_phuc_vu', esc_html( $woocommerce_textarea ) ); }
  • Code show new field dưới phần short description 
function show_khuyen_mai(){ global $post; $get_khuyen_mai = get_post_meta($post->ID,"_khuyen_mai",true); $_thi_truong_phuc_vu = get_post_meta($post->ID,"_thi_truong_phuc_vu",true); ?> 
Khuyến mãi

Tin nổi bật trong ngày
Tin mới nhất

Register

Newsletter

Email this story
If you really want to disable all recommended stories, click on OK button. After that, you will be redirect to your options page.