Skip to content

Instantly share code, notes, and snippets.

@jan-koch
Created November 15, 2018 13:09
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jan-koch/5dd8897b974969ed66204e92f6a05ef4 to your computer and use it in GitHub Desktop.
Save jan-koch/5dd8897b974969ed66204e92f6a05ef4 to your computer and use it in GitHub Desktop.
Example of adding a select box to the "General" product data tab.
<?php
function prefix_add_selectbox() {
$args = array(
'id' => 'my_new_select', // required. The meta_key ID for the stored value
'wrapper_class' => '', // a custom wrapper class if needed
'desc_tip' => true, // makes your description show up with a "?" symbol and as a tooltip
'description' => __('My awesome select box', 'your_text_domain'),
'label' => __( 'My New Select', 'your_text_domain' ),
'options' => array(
'value1' => __( 'Text 1', 'your_text_domain' ),
'value2' => __( 'Text 2', 'your_text_domain' )
)
);
woocommerce_wp_select( $args );
}
add_action( 'woocommerce_product_options_tax', 'prefix_add_selectbox' );
@elmatador1170
Copy link

That's what I thought.

Still thanks Jan!

@jimvadams
Copy link

Hi Jan, thanks for this amazing code snippet, is there an option to make the new Field appears in the quick edit page?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment