Skip to content

Instantly share code, notes, and snippets.

@ville6000
Created October 16, 2018 07:03
Show Gist options
  • Save ville6000/78d5f69f109f3bb74fe369d8852b72f3 to your computer and use it in GitHub Desktop.
Save ville6000/78d5f69f109f3bb74fe369d8852b72f3 to your computer and use it in GitHub Desktop.
How to add fields to WooCommerce products general tab
<?php
add_action( 'woocommerce_product_options_general_product_data', 'add_my_custom_data' );
public function add_my_custom_data() {
global $post;
?>
<div class="options_group">
<?php
woocommerce_wp_text_input( [
'id' => '_my_custom_data_key',
'value' => get_post_meta( $post->ID, '_my_custom_data_key', true ),
'label' => __( 'My Custom Data', 'my-text-domain' ),
'custom_attributes' => [
'disabled' => 'disabled',
],
] );
?>
</div>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment