Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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