Version 5.6.2 release on 3rd of August 2023
Your content goes here. Edit or remove this text inline or in the module Content settings. You can also style every aspect of this content in the module Design settings and even apply custom CSS to this text in the module Advanced settings.
Changes:
- Fix product column raffle view – currently products in the list were not showing to which raffle it links.
- Added new shortcode [raffle name=’info’ id=’0′] with options info as the type of data to retrieve and id as raffle id.
Q: What the new shortcode does?
A: It will retrieve information about the raffle, and it can be placed anywhere on the site, in combination with other plugins like progress bar, or custom code.
Q: How to use it?
A: Copy the shortcode in any page or post, or block, and it should execute as shortcode. Next you need to go into your child them functions.php and add a custom filter to display the custom data as such:
The line below will get you started on how to display custom data about the raffle
add_filter('raffle_info_filter', 'funct_raffle_filter', 10, 2 ); function funct_raffle_filter( $content, $raffle_obj ){ $content = "<p>Raffle Information</p>"; return $content; }
$raffle_object parameter is an associative array with the following keys values:
$raffle_id = $raffle_obj['raffle_id']; // get the raffle id $raffle_name = $raffle_obj['raffle_name']; //raffle name $start_ticket = $raffle_obj['start_ticket']; //starting ticket number $limit_tickets = $raffle_obj['limit_tickets']; //limit number of tickets, if not limit 'unlimited' is returned $sold_tickets = $raffle_obj['sold_tickets']; //number of sold tickets $last_sold_ticket = $raffle_obj['last_sold_ticket']; //last sold ticket number $last_sold_prefixed = $raffle_obj['last_sold_prefixed']; //last sold ticket with prefix attached $prefix = $raffle_obj['prefix']; //prefix string $start_datetime = $raffle_obj['start_datetime']; //start date as epoch (number) $end_datetime = $raffle_obj['end_datetime']; //end date as epoch (number) $start_date_string = $raffle_obj['start_date_string']; //start date as string $end_date_string = $raffle_obj['end_date_string']; //end date as string
With content being the html container, and the $raffle_obj array holding the data, custom progress bar can be constructed or combined with other plugins.
Below is the example from the YouTube video
Plugins needed for this example:
add_filter('raffle_info_filter', 'funct_raffle_filter', 10, 2 ); function funct_raffle_filter( $content, $raffle_obj ){ $content = ''; $raffle_id = $raffle_obj['raffle_id']; //raffle id $raffle_name = $raffle_obj['raffle_name']; //raffle name $start_ticket = $raffle_obj['start_ticket']; //raffle starting number $limit_tickets = $raffle_obj['limit_tickets']; //number of total tickets if not 'unlimited', else number $sold_tickets = $raffle_obj['sold_tickets']; //number of sold tickets $last_sold_ticket = $raffle_obj['last_sold_ticket']; //last sold ticket $last_sold_prefixed = $raffle_obj['last_sold_prefixed']; //last sold with prefix $prefix = $raffle_obj['prefix']; //prefix $start_datetime = $raffle_obj['start_datetime']; //1690911878, 0 $end_datetime = $raffle_obj['end_datetime']; //1690921878 $start_date_string = $raffle_obj['start_date_string']; //Tue, 01 Aug 2023 17:44:36 GMT $end_date_string = $raffle_obj['end_date_string']; $is_terminated = $raffle_obj['is_terminated']; // true/false $raffle_class = 'custom-raffle-class-'. $raffle_id; $left_for_sale = $limit_tickets - $sold_tickets; $content .= "<hr />"; $content .= "<p> Raffle has " . ( $is_terminated ? 'finished' : 'not finished') . "</p>"; $content .= "<div class='${raffle_class}'> <p> Raffle: ${raffle_name}, Tickets sold: ${sold_tickets} </p>"; if( $raffle_id == 0 && $limit_tickets !== 'unlimited' ){ //default raffle $content .= do_shortcode("[wppb progress='${sold_tickets}/${limit_tickets}']"); }else if( $raffle_id == 1 && $limit_tickets !== 'unlimited'){ $percent = 0; if( $sold_tickets != 0 ){ $percent = (int) ceil( round( $sold_tickets / $limit_tickets * 100) ); } $content .= do_shortcode("[circle_progress fill=${percent} color='yellow' size='big']"); } $content .= "<div> <p> Raffle: ${raffle_name}, Ticket sold: ${sold_tickets} </p>"; $content .= "<p> Tickets left for sale: ${left_for_sale} </p>"; $content .= "<p> Last sold ticket: ${last_sold_ticket} </p>"; $content .= "</div>"; return $content; }