Spät in der Zeit, aber Sie können verwendet werden:
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'])
);
}
$ Feld Array meiner Meinung nach mindestens haben muss:
$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
);
Sie können auch Folgendes angeben:
'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
Die Tabelle, die Sie sehen Mischung aus HTML in 'th' und' tfoot' ist, während die Daten gefüllt wird mit Schnurrbart Underscore.js Vorlagen inspiriert. Weitere Informationen finden Sie unter '\ includes \ admin \ settings \ views \ html-admin-page-shipping-zone-methods.php'. –
Das Modell für die Versandmethodeneinstellungen basiert ebenfalls auf der Vorlage Underscore.js. Um die Ansicht zu ändern und die eingegebenen Daten zu verarbeiten, müssen Sie also Custom JS verwenden. Zum Speichern/Abrufen des Datenteils können Sie die Kerneinstellungen api verwenden und in Optionen speichern. Um diese am Frontend anzuzeigen, müssen Sie in jeder WC-Vorlage Hooks verwenden. –