Created
September 6, 2019 13:36
-
-
Save BKeanu1989/88950572b392878d2c39a87daff6aa80 to your computer and use it in GitHub Desktop.
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
function woo_add_product_gender() { | |
echo '<div class="options_group">'; | |
woocommerce_wp_select( | |
array( | |
'id' => '_product_gender', | |
'label' => __( 'Gender', 'woocommerce' ), | |
'options' => array( | |
'male' => __( 'Male', 'woocommerce' ), | |
'female' => __( 'Female', 'woocommerce' ), | |
'unisex' => __( 'Unisex', 'woocommerce' ) | |
) | |
) | |
); | |
echo '</div>'; | |
} | |
function woo_add_product_gender_save( $post_id ) { | |
$woocommerce_dropdown_field = $_POST['_product_gender']; | |
if ( !empty( $woocommerce_dropdown_field )) { | |
update_post_meta( $post_id , '_product_gender', esc_attr( $woocommerce_dropdown_field )); | |
} | |
} | |
// Display Fields | |
add_action( 'woocommerce_product_options_general_product_data', 'woo_add_product_gender' ); | |
// Save Fields | |
add_action( 'woocommerce_process_product_meta', 'woo_add_product_gender_save' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment