Created
October 25, 2013 11:08
-
-
Save corsonr/7153007 to your computer and use it in GitHub Desktop.
woocommerce custom field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Display Fields | |
add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' ); | |
// Save Fields | |
add_action( 'woocommerce_process_product_meta', 'woo_add_custom_general_fields_save' ); | |
function woo_add_custom_general_fields() { | |
global $woocommerce, $post; | |
// Text Field | |
woocommerce_wp_textarea_input( | |
array( | |
'id' => '_textarea', | |
'label' => __( 'My Textarea', 'woocommerce' ), | |
'placeholder' => '', | |
'desc_tip' => 'true', | |
'description' => __( 'Enter the custom value here.', 'woocommerce' ) | |
) | |
); | |
} | |
function woo_add_custom_general_fields_save( $post_id ){ | |
// Textarea | |
$woocommerce_textarea = $_POST['_textarea']; | |
if( !empty( $woocommerce_textarea ) ) | |
update_post_meta( $post_id, '_textarea', esc_html( $woocommerce_textarea ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
http://prntscr.com/50wd3w - on line 248 what hook should I call for the 'product_tab_options' method, while I want that content to appear only on the 'Wrappers' tab?
Thanks,
Miklós