wpgenie icon

Lottery History sorted by ticket number (using filter)

wpgenie | PRO | 03/27/25 07:51:03 AM UTC (Edited) | 0 ⭐ | 10537 👁️ | Never ⏰ | []
PHP |

950 B

|

None

|

0 👍

/

0 👎

add_filter( 'woocomerce_lottery_history', 'woocomerce_lottery_history_sort_by_ticket_number', 15 , 4 );
 
function woocomerce_lottery_history_sort_by_ticket_number( $history, $product_id, $user_id, $relisteddate ){
        global $wpdb;
        $wheredatefrom = '';
        $datefrom      = FALSE;
        $relisteddate  = get_post_meta( $product_id, '_lottery_relisted', true );
        if(!is_admin() && !empty($relisteddate)){
            $datefrom = $relisteddate;
        }
        if($datefrom){
            $wheredatefrom =" AND CAST(date AS DATETIME) > '$datefrom' ";
        }
        if($user_id){
            $wheredatefrom =" AND wc_lottery_log.userid = $user_id";
        }
        $history = $wpdb->get_results( 'SELECT * FROM '.$wpdb->prefix.'wc_lottery_log LEFT JOIN '.$wpdb->prefix.'wc_lottery_pn_log on '.$wpdb->prefix.'wc_lottery_log.id = '.$wpdb->prefix.'wc_lottery_pn_log.log_id WHERE '.$wpdb->prefix.'wc_lottery_log.lottery_id =' . $product_id . $wheredatefrom.' ORDER BY `ticket_number` ASC');
        return $history;
}
 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎