Skip to content

Instantly share code, notes, and snippets.

@jan-koch
Created November 15, 2018 10:35
Show Gist options
  • Save jan-koch/cfa2731ff5755fe297990269dd816e2b to your computer and use it in GitHub Desktop.
Save jan-koch/cfa2731ff5755fe297990269dd816e2b to your computer and use it in GitHub Desktop.
Example for adding a text input field to the WooCommerce "General" tab.
<?php
function prefix_add_text_input() {
$args = array(
'label' => '', // Text in the label in the editor.
'placeholder' => '', // Give examples or suggestions as placeholder
'class' => '',
'style' => '',
'wrapper_class' => '',
'value' => '', // if empty, retrieved from post_meta
'id' => '', // required, will be used as meta_key
'name' => '', // name will be set automatically from id if empty
'type' => '',
'desc_tip' => '',
'data_type' => '',
'custom_attributes' => '', // array of attributes you want to pass
'description' => ''
);
woocommerce_wp_text_input( $args );
}
add_action( 'woocommerce_product_options_pricing', 'prefix_add_text_input' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment