Created
June 23, 2020 15:07
-
-
Save namncn/75423bf7898d44c2d48a859bf2e148f5 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
<?php | |
function pixelplus_add_woo_custom_general_fields() { | |
global $woocommerce, $post; | |
echo '<div class="options_group">'; | |
woocommerce_wp_checkbox( | |
array( | |
'id' => '_hot_product', | |
'label' => __( 'Sản phẩm Hot?', 'pixelplus' ), | |
) | |
); | |
echo '</div>'; | |
} | |
add_action( 'woocommerce_product_options_general_product_data', 'pixelplus_add_woo_custom_general_fields' ); | |
function pixelplus_add_woo_custom_general_fields_save( $post_id ) { | |
$_hot_product = $_POST['_hot_product']; | |
if ( isset( $_hot_product ) && $_hot_product ) { | |
update_post_meta( $post_id, '_hot_product', $_hot_product ); | |
} | |
} | |
add_action( 'woocommerce_process_product_meta', 'pixelplus_add_woo_custom_general_fields_save' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment