Automattic\WooCommerce\Internal\Admin\Orders\MetaBoxes
CustomMetaBox::render_meta_form
Reimplementation of WP core's meta_form function. Renders meta form box.
Method of the class: CustomMetaBox{}
No Hooks.
Returns
null
. Nothing (null).
Usage
$CustomMetaBox = new CustomMetaBox(); $CustomMetaBox->render_meta_form( $order ) : void;
- $order(WC_Order) (required)
- WC_Order object.
CustomMetaBox::render_meta_form() CustomMetaBox::render meta form code WC 9.9.4
<?php public function render_meta_form( \WC_Order $order ) : void { ?> <p><strong><?php esc_html_e( 'Add New Custom Field:', 'woocommerce' ); ?></strong></p> <table id="newmeta"> <thead> <tr> <th class="left"><label for="metakeyselect"><?php esc_html_e( 'Name', 'woocommerce' ); ?></label></th> <th><label for="metavalue"><?php esc_html_e( 'Value', 'woocommerce' ); ?></label></th> </tr> </thead> <tbody> <tr> <td id="newmetaleft" class="left"> <span id="metakey-search"> <select id="metakeyselect" name="metakeyselect" class="wc-order-metakey-search" data-placeholder="<?php esc_attr_e( 'Add existing', 'woocommerce' ); ?>" data-minimum-input-length="0" data-order_id="<?php echo esc_attr( $order->get_id() ); ?>"> </select> </span> <input class="hidden" type="text" id="metakeyinput" name="metakeyinput" value="" aria-label="<?php esc_attr_e( 'New custom field name', 'woocommerce' ); ?>" /> <button type="button" id="newmeta-button" class="button button-small hide-if-no-js" onclick="jQuery('#metakeyinput, #metakeyselect, #enternew, #cancelnew, #metakey-search').toggleClass('hidden');jQuery('#metakeyinput, #metakeyselect').filter(':visible').trigger('focus');"> <span id="enternew"><?php esc_html_e( 'Enter new', 'woocommerce' ); ?></span> <span id="cancelnew" class="hidden"><?php esc_html_e( 'Cancel', 'woocommerce' ); ?></span> </td> <td><textarea id="metavalue" name="metavalue" rows="2" cols="25"></textarea> <?php wp_nonce_field( 'add-meta', '_ajax_nonce-add-meta', false ); ?> </td> </tr> </tbody> </table> <div class="submit add-custom-field"> <?php submit_button( __( 'Add Custom Field', 'woocommerce' ), '', 'addmeta', false, array( 'id' => 'newmeta-submit', 'data-wp-lists' => 'add:the-list:newmeta', ) ); ?> </div> <?php }