2016-11-08 5 views
1

검색 방법 woocomerce에서 viriable 제품에 대한 사용자 정의 필드를 추가 할 수 있습니까? 나는 이미 이것을하고 있지만, 단순한 제품에 대해서만 일하고있다.사용자 정의 필드 woocomerce 추가 (변수 제품)

add_action('woocommerce_product_options_general_product_data', 'wc_custom_add_custom_fields'); 
function wc_custom_add_custom_fields() { 
    // Print a custom text field 
    woocommerce_wp_text_input(array(
     'id' => '_custom_text_field', 
     'label' => 'Custom Text Field', 
     'description' => 'This is a custom field, you can write here anything you want.', 
     'desc_tip' => 'true', 
     'placeholder' => 'Custom text' 
    )); 
} 
add_action('woocommerce_process_product_meta', 'wc_custom_save_custom_fields'); 
function wc_custom_save_custom_fields($post_id) { 
    if (! empty($_POST['_custom_text_field'])) { 
     update_post_meta($post_id, '_custom_text_field', esc_attr($_POST['_custom_text_field'])); 
    } 
} 

어떻게하면 가변 제품에 대해 수정할 수 있습니까? 감사

답변

-1

그냥

add_action('woocommerce_product_options_general_product_data', 'wc_custom_add_custom_fields'); 

add_action('woocommerce_product_options_inventory_product_data', 'wc_custom_add_custom_fields'); 

에 및 사용자 정의 필드 목록 탭에있을 것입니다 변경

관련 문제