2016-11-08 10 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_inventory_product_data', 'wc_custom_add_custom_fields'); 

add_action('woocommerce_product_options_general_product_data', 'wc_custom_add_custom_fields'); 

を変更して、カスタムフィールドは、在庫タブ

になります
関連する問題