SHARE
TWEET

Add lottery counter in the loop

wpgenie Aug 29th, 2016 (edited) 501 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         add_action( 'woocommerce_after_shop_loop_item_title','wpgenie_show_counter_in_loop',50 );
  2.  
  3.         function wpgenie_show_counter_in_loop(){
  4.  
  5.             global $product;
  6.  
  7.             $time = '';
  8.  
  9.             if(!isset ($product))
  10.                 return;
  11.             if('lottery' != $product->product_type)
  12.                 return;
  13.  
  14.             $timetext = __('Time left', 'wc_lottery');
  15.  
  16.             if(!$product->is_started()){
  17.                 $timetext = __('Starting in', 'wc_lottery');
  18.                 $counter_time = $product->get_seconds_to_lottery();
  19.             } else{
  20.                 $counter_time = $product->get_seconds_remaining();
  21.             }
  22.  
  23.             $time = '<span class="time-left">'.$timetext.'</span>
  24.             <div class="lottery-time-countdown"
  25.             data-time="'.$counter_time.'"
  26.             data-lotteryid="'.$product->id.'" data-format="'.get_option( 'simple_lottery_countdown_format' ).'"></div>';
  27.  
  28.             if($product->is_closed()){
  29.                 $time = '<span class="has-finished">'.__('Lottery finished','wc_lottery').'</span>';
  30.             }
  31.             echo $time;
  32.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top