wpgenie

Change text on Lottery Ticket Plugin

Sep 26th, 2022 (edited)
1,775
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.46 KB | None | 0 0
  1. add_action( 'woocommerce_product_options_lottery', 'custom_woocommerce_product_options_lottery', 20);
  2.  
  3. function custom_woocommerce_product_options_lottery(){
  4.     woocommerce_wp_textarea_input(
  5.                     array(
  6.                         'id'                => '_lottery_custom_ticket_names',
  7.                         'wrapper_class'     => '',
  8.                         'description'       => __( 'Enter ticket names separated with ","', 'wc-lottery-pn' ),
  9.                         'label'             => __( 'Ticket names', 'wc_lottery' ),
  10.                         'desc_tip'          => 'false',
  11.                     )
  12.                 );
  13. }
  14.  
  15. add_action( 'lottery_product_save_data' , 'custom_lottery_product_save_data' , 10, 2 );
  16. function custom_lottery_product_save_data( $post_id, $post  ){
  17.  
  18.     if ( isset( $_POST['_lottery_custom_ticket_names'] ) && ! empty( $_POST['_lottery_custom_ticket_names'] ) ) {
  19.         update_post_meta( $post_id, '_lottery_custom_ticket_names', $_POST['_lottery_custom_ticket_names'] );
  20.     } else {
  21.         delete_post_meta( $post_id, '_lottery_custom_ticket_names' );
  22.     }
  23. }
  24.  
  25.  
  26. add_filter( 'change_ticket_numbers_to_alphabet', 'custom_ticket_number_display_html', 1, 3);
  27.  
  28. function custom_ticket_number_display_html( $ticket_number, $_ticket_number, $product ){
  29.     $lottery_custom_ticket_names = get_post_meta( $product->get_id(), '_lottery_custom_ticket_names', true );
  30.     $names_array  = explode(',', $lottery_custom_ticket_names);
  31.     if ( isset( $names_array[ intval($_ticket_number ) -1 ] ) ){
  32.         return trim( $names_array[ intval($_ticket_number ) -1 ] );
  33.     }
  34.     return $ticket_number;
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment