Last active
          August 5, 2025 09:32 
        
      - 
      
 - 
        
Save igorbenic/1106ccf44c1061d80c2738bcbe09181d to your computer and use it in GitHub Desktop.  
Revisions
- 
        
igorbenic revised this gist
May 6, 2017 . 1 changed file with 13 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ <?php add_action( 'woocommerce_process_product_meta', 'save_custom_field' ); function save_custom_field( $post_id ) { $custom_field_value = isset( $_POST['my_custom_input'] ) ? $_POST['my_custom_input'] : ''; $product = wc_get_product( $post_id ); $product->update_meta_data( 'my_custom_input', $custom_field_value ); $product->save(); }  - 
        
igorbenic revised this gist
May 6, 2017 . 3 changed files with 52 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ <?php add_action( 'woocommerce_product_write_panel_tabs', 'my_custom_tab_action' ); /** * Adding a custom tab */ function my_custom_tab_action() { ?> <li class="custom_tab"> <a href="#the_custom_panel"> <span><?php _e( 'My Custom Tab', 'textdomain' ); ?></span> </a> </li> <?php } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ <?php add_filter( 'woocommerce_product_data_tabs', 'my_custom_tab' ); /** * Adding a custom tab */ function my_custom_tab( $tabs ) { $tabs['custom_tab'] = array( 'label' => __( 'My Custom Tab', 'textdomain' ), 'target' => 'the_custom_panel', 'class' => array(), ); return $tabs; } This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ <?php add_action( 'woocommerce_product_data_panels', 'custom_tab_panel' ); function custom_tab_panel() { ?> <div id="the_custom_panel" class="panel woocommerce_options_panel"> <div class="options_group"> <?php $field = array( 'id' => 'my_custom_input', 'label' => __( 'Custom Input', 'textdomain' ), ); woocommerce_wp_text_input( $field ); ?> </div> </div> <?php }  - 
        
igorbenic revised this gist
May 6, 2017 . 1 changed file with 32 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ <?php add_action( 'woocommerce_product_options_pricing', 'my_woo_custom_price_field' ); /** * Add a Christmas Price field **/ function my_woo_custom_price_field() { $field = array( 'id' => 'christmas_price', 'label' => __( 'Christmas Price', 'textdomain' ), 'data_type' => 'price' //Let WooCommerce formats our field as price field ); woocommerce_wp_text_input( $field ); } add_action( 'woocommerce_product_options_general_product_data', 'my_woo_custom_fields' ); /** * Add a select Field at the bottom */ function my_woo_custom_fields() { $select_field = array( 'id' => 'my_select', 'label' => __( 'Custom Select', 'textdomain' ), 'options' => array( 'value1' => __( 'Text 1', 'textdomain' ), 'value2' => __( 'Text 2', 'textdomain' ) ) ); woocommerce_wp_select( $select_field ); }  - 
        
igorbenic created this gist
May 6, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ <?php $args = array( 'label' => '', // Text in Label 'class' => '', 'style' => '', 'wrapper_class' => '', 'value' => '', // if empty, retrieved from post meta where id is the meta_key 'id' => '', // required 'name' => '', //name will set from id if empty 'cbvalue' => '', 'desc_tip' => '', 'custom_attributes' => '', // array of attributes 'description' => '' ); woocommerce_wp_checkbox( $args ); This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ <?php $args = array( 'value' => '', 'class' => '', 'id' => '' ); woocommerce_wp_hidden_input( $args ); This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ <?php $args = array( 'label' => '', // Text in Label 'class' => '', 'style' => '', 'wrapper_class' => '', 'value' => '', // if empty, retrieved from post meta where id is the meta_key 'id' => '', // required 'name' => '', //name will set from id if empty 'options' => '', // Options for radio inputs, array 'desc_tip' => '', 'description' => '' ); woocommerce_wp_radio( $args ); This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ <?php $args = array( 'label' => '', // Text in Label 'class' => '', 'style' => '', 'wrapper_class' => '', 'value' => '', // if empty, retrieved from post meta where id is the meta_key 'id' => '', // required 'name' => '', //name will set from id if empty 'options' => '', // Options for select, array 'desc_tip' => '', 'custom_attributes' => '', // array of attributes 'description' => '' ); woocommerce_wp_select( $args ); This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ <?php $args = array( 'label' => '', // Text in Label 'placeholder' => '', 'class' => '', 'style' => '', 'wrapper_class' => '', 'value' => '', // if empty, retrieved from post meta where id is the meta_key 'id' => '', // required 'name' => '', //name will set from id if empty 'type' => '', 'desc_tip' => '', 'data_type' => '', 'custom_attributes' => '', // array of attributes 'description' => '' ); woocommerce_wp_text_input( $args ); This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ <?php $args = array( 'label' => '', // Text in Label 'placeholder' => '', 'class' => '', 'style' => '', 'wrapper_class' => '', 'value' => '', // if empty, retrieved from post meta where id is the meta_key 'id' => '', // required 'name' => '', //name will set from id if empty 'rows' => '', 'cols' => '', 'desc_tip' => '', 'custom_attributes' => '', // array of attributes 'description' => '' ); woocommerce_wp_textarea_input( $args );