wpgenie

woocommerce_lottery_product_loop_lotteries_winners_header

Sep 13th, 2023 (edited)
952
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.26 KB | None | 0 0
  1. /*
  2. This code should go to your child theme functions.php file
  3.  
  4. example how to use new actions woocommerce_lottery_product_loop_lotteries_winners_header, woocommerce_lottery_product_loop_lotteries_winners_body
  5.  
  6. */
  7. add_action( 'woocommerce_lottery_product_loop_lotteries_winners_header', 'custom_add_ticket_numbers_to_winner_list_header' );
  8.  
  9.  
  10. function custom_add_ticket_numbers_to_winner_list_header(){
  11.     echo '<th>' . __('Ticket','wc_lottery-pn') . '</th>';
  12. }
  13.  
  14.  
  15. add_action( 'woocommerce_lottery_product_loop_lotteries_winners_body', 'custom_add_ticket_numbers_to_winner_list_body', 10, 2 );
  16. function custom_add_ticket_numbers_to_winner_list_body( $product_id, $product ){
  17.     $lottery_winers  = get_post_meta($product_id, '_lottery_pn_winners',true);
  18.     echo '<td>';
  19.     if( $lottery_winers ) {
  20.         if (count($lottery_winers) > 1) {
  21.             $winners = '';
  22.             foreach ($lottery_winers as $winner) {
  23.                     $winners .=  apply_filters( 'ticket_number_display_html' ,$winner['ticket_number'], $product );
  24.  
  25.  
  26.             }
  27.             echo rtrim ($winners, ', ');
  28.         } else {
  29.             if ( isset( $lottery_winers[0]['ticket_number'] ) ) {
  30.                 echo  apply_filters( 'ticket_number_display_html', $lottery_winers[0]['ticket_number'], $product) ;
  31.             }
  32.         }
  33.     }
  34.     echo '</td>';
  35.  
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment