Created
November 15, 2018 13:09
-
-
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.
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
<?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' ); |
I don't know how to do that because I don't have any PHP experience. Can you maybe suggest any code which could help me?
thanks in advance
Hey,
I'm sorry but I think if you don't have any PHP experience, this task is
too far ahead of your skillset. It's easy to break a website when messing
with PHP and not understanding what you're doing.
I'd recommend you first learn about PHP and WordPress child theme
development. Here is a fantastic book to get started:
https://digwp.com/book/
Best,
Jan
…On Wed, Mar 4, 2020 at 7:29 PM elmatador1170 ***@***.***> wrote:
I don't know how to do that because I don't have any PHP experience. Can
you maybe suggest any code which could help me?
thanks in advance
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<https://gist.github.com/5dd8897b974969ed66204e92f6a05ef4?email_source=notifications&email_token=ACR7C2HUNJ3C7QIXVDWEX33RF2MZZA5CNFSM4LAVMGA2YY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAGDKO6#gistcomment-3200239>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACR7C2BFSMISYC6ZEQMX3ELRF2MZZANCNFSM4LAVMGAQ>
.
--
Best regards,
Jan
Blog <http://jkoch.me>
Facebook <https://facebook.com/iamjankoch>
Twitter <https://twitter.com/iamjankoch>
That's what I thought.
Still thanks Jan!
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
You would extend your child theme and query the field using get_post_meta(). Field ID is set in line 4 in my code, that's what you'd reference in get_post_meta().