Created
November 15, 2018 14:54
-
-
Save jan-koch/312cfc891e7118f29a2fc99f13af7612 to your computer and use it in GitHub Desktop.
Example for implementing a checkbox as WooCommerce product meta field, in the "General" 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_checkbox() { | |
$args = array( | |
'label' => '', // Text in the editor label | |
'class' => '', | |
'style' => '', | |
'wrapper_class' => '', // custom CSS class for styling | |
'value' => '', // meta_value where the id serves as meta_key | |
'id' => '', // required, it's the meta_key for storing the value (is checked or not) | |
'name' => '', | |
'cbvalue' => '', // "value" attribute for the checkbox | |
'desc_tip' => '', // true or false, show description directly or as tooltip | |
'custom_attributes' => '', // array of attributes | |
'description' => '' // provide something useful here | |
); | |
woocommerce_wp_checkbox( $args ); | |
} | |
add_action( 'woocommerce_product_options_tax', 'prefix_add_checkbox' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ja, ist kein Problem. Das kannst du über get_post_meta() laden und dann in der Produkt Admin-Ansicht einbinden. Hier ist ein guter Artikel dazu: https://www.cloudways.com/blog/add-custom-product-fields-woocommerce/