2017-05-18 15 views
6

मैं शिपिंग विधि के तहत शिपिंग क्षेत्र पृष्ठ में एक कस्टम फ़ील्ड जोड़ना चाहता हूं, यह एक टेक्स्ट इनपुट होगा, उपयोगकर्ता एक कस्टम संदेश जोड़ने में सक्षम होगा और मैं दिखाऊंगा उस संदेश को सामने के अंत में।शिपिंग विधियों में कस्टम विवरण फ़ील्ड को जोड़ने के लिए कैसे करें (बैकएंड)

मैंने देखा कि यह wp_woocommerce_shipping_zone_methods तालिका में डेटा सहेजता है जिसमें डेटा को सहेजने के लिए कोई अतिरिक्त कॉलम नहीं है; इसलिए मुझे लगता है कि मुझे अपने कस्टम तर्क का उपयोग करना है, लेकिन मुझे हुक (ओं) का नाम नहीं पता है।

तो मेरी सवाल है, वहाँ है किसी भी हुक जो मदद मिलेगी है/मुझे

  1. एक कस्टम फ़ील्ड जोड़ने के लिए अनुमति देते हैं।
  2. कस्टम कॉलम जोड़ने के लिए।

टी एल; डॉ: enter image description here

enter image description here

+0

तालिका आप देखते हैं कि HTML के मिश्रण में 'th' और' tfoot' है, जबकि डेटा का उपयोग कर मूंछें Underscore.js टेम्पलेट्स प्रेरित भर जाता है। अधिक जानकारी के लिए आप '\ include \ admin \ settings \ views \ html-admin-page-shipping-zone-methods.php' देख सकते हैं। –

+0

शिपिंग विधि सेटिंग्स का मॉडल Underscore.js टेम्पलेट पर भी आधारित है। तो दर्ज डेटा को देखने और संसाधित करने के लिए आपको कस्टम जेएस का उपयोग करना होगा। डेटा भाग को संग्रहीत/पुनर्प्राप्त करने के लिए आप कोर सेटिंग्स एपीआई का उपयोग करके ऐसा कर सकते हैं और उन्हें विकल्पों में सहेज सकते हैं। फ्रंटएंड पर इसे प्रदर्शित करने के लिए आपको प्रत्येक डब्ल्यूसी टेम्पलेट में हुक का उपयोग करना होगा। –

उत्तर

0
देर समय में

लेकिन आप उपयोग कर सकते हैं:

:

मेरी राय में
add_action('woocommerce_product_options_general_product_data', 'my_custom_fields'); 

function my_custom_fields() { 
    $field = array(
     //This ID will be use on the _postmeta table as key_name 
     'id' => 'my_custom_message', 
     //Text that goes inside the label tag 
     'label' => 'Message:', 
     //This text will appear on the description column 
     'description' => 'This is a custom message not part of WooCommerce', 
     //Boolean that determines the display of the description 
     'desc_tip' => true, 
     //Standard html input placeholder 
     'placeholder' => 'Type a message', 
    ); 
    woocommerce_wp_text_input($field); 
} 

add_action('woocommerce_process_product_meta', 'save_my_custom_fields'); 

function save_my_custom_fields($post_id) { 
    update_post_meta(
     $post_id, 
     'my_custom_message', 
     esc_attr($POST['my_custom_message']) 
    ); 
} 

$ क्षेत्र सरणी कम से कम होना चाहिए

$field = array(
    'id' => 'my_custom_message',//This ID will be use on the _postmeta table as key_name 
    'label' => 'Message:',//Text that goes inside the label tag 
    'description' => 'This is a custom message not part of WooCommerce',//This text will appear on the description column 
    'desc_tip' => true,//Boolean that determines the display of the description 
    'placeholder' => 'Type a message',//Standard html input placeholder 
); 

आप निम्न निर्दिष्ट कर सकता है:

'class' => 'css-class',//Class attributte for the input tag 
    'style' => 'background:red',//Style attribute for the input tag 
    'wrapper_class' => 'css-class',//Class for the wrapper of the input tag, it is a paragraph 
संबंधित मुद्दे