wpgenie

show lottery sold tickets bar in loop / archive

Mar 2nd, 2018 (edited)
505
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* available as plugin https://wpgenie.org/woocommerce-lottery/documentation/assets/woocommerce-lottery-progress-bar-in-loop.zip */
  2.  
  3. add_action( 'woocommerce_after_shop_loop_item', 'show_progress_bar_in_loop',6 );
  4. function show_progress_bar_in_loop (){
  5.     global $product;
  6.  
  7.     if ( method_exists( $product, 'get_type') && $product->get_type() == 'lottery' ) :
  8.         $lottery_participants_count = !empty($product->get_lottery_participants_count()) ? $product->get_lottery_participants_count() : '0';
  9.     ?>
  10.         <div class="wcl-progress-meter <?php if($product->is_max_tickets_met()) echo 'full' ?>">
  11.             <span class="zero">0</span>
  12.             <span class="max"><?php echo $product->get_max_tickets(); ?></span>
  13.             <progress  max="<?php echo $product->get_max_tickets(); ?>" value="<?php echo $lottery_participants_count ?>"  low="<?php echo $product->get_min_tickets(); ?>"></progress>
  14.         </div>
  15.     <?php endif;
  16. }
RAW Paste Data