Skip to content

Instantly share code, notes, and snippets.

@namncn
Created June 23, 2020 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save namncn/75423bf7898d44c2d48a859bf2e148f5 to your computer and use it in GitHub Desktop.
Save namncn/75423bf7898d44c2d48a859bf2e148f5 to your computer and use it in GitHub Desktop.
<?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