Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- This code should go to your child theme functions.php file
- example how to use new actions woocommerce_lottery_product_loop_lotteries_winners_header, woocommerce_lottery_product_loop_lotteries_winners_body
- */
- add_action( 'woocommerce_lottery_product_loop_lotteries_winners_header', 'custom_add_ticket_numbers_to_winner_list_header' );
- function custom_add_ticket_numbers_to_winner_list_header(){
- echo '<th>' . __('Ticket','wc_lottery-pn') . '</th>';
- }
- add_action( 'woocommerce_lottery_product_loop_lotteries_winners_body', 'custom_add_ticket_numbers_to_winner_list_body', 10, 2 );
- function custom_add_ticket_numbers_to_winner_list_body( $product_id, $product ){
- $lottery_winers = get_post_meta($product_id, '_lottery_pn_winners',true);
- echo '<td>';
- if( $lottery_winers ) {
- if (count($lottery_winers) > 1) {
- $winners = '';
- foreach ($lottery_winers as $winner) {
- $winners .= apply_filters( 'ticket_number_display_html' ,$winner['ticket_number'], $product );
- }
- echo rtrim ($winners, ', ');
- } else {
- if ( isset( $lottery_winers[0]['ticket_number'] ) ) {
- echo apply_filters( 'ticket_number_display_html', $lottery_winers[0]['ticket_number'], $product) ;
- }
- }
- }
- echo '</td>';
- }
Advertisement
Add Comment
Please, Sign In to add comment