the code i used for custom field
add_action( 'woocommerce_product_options_advanced', 'ws_adv_product_options');
function ws_adv_product_options(){
echo '<div class="options_group">';
woocommerce_wp_text_input( array(
'id' => 'winner_select',
'value' => get_post_meta( get_the_ID(), 'winner_select', true ),
'label' => 'Winner Name'
) );
echo '</div>';
}
add_action( 'woocommerce_process_product_meta', 'ws_save_fields', 10, 2 );
function ws_save_fields( $id, $post ){
if( !empty( $_POST['winner_select'] ) ) {
update_post_meta( $id, 'winner_select', $_POST['winner_select'] );
} else {
delete_post_meta( $id, 'winner_select' );
}
}
If the winner’s name is entered in the field and the product is updated. A mail should be sent to all users who have previously purchased the product
mail content
Subject: Lucky Winner Selected for [product name]
message: some text [winner name]
-
This reply was modified 3 years, 3 months ago by
roghithsam.
-
This reply was modified 3 years, 3 months ago by
roghithsam.