View difference between Paste ID: gavzf7bz and v3iMcG1k
SHOW: | | - or go back to the newest paste.
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_title','wpgenie_show_counter_in_loop',50 );
4
5
		function wpgenie_show_counter_in_loop(){
6
7
			global $product;
8
9
			$time = '';
10
11-
			if('lottery' != $product->product_type)
11+
12
				return;
13
			if('lottery' != $product->get_type())
14
				return;
15
16
			$timetext = __('Time left', 'wc_lottery');
17
18
			if(!$product->is_started()){
19
				$timetext = __('Starting in', 'wc_lottery');
20
				$counter_time = $product->get_seconds_to_lottery();
21
			} else{
22
				$counter_time = $product->get_seconds_remaining();
23
			}
24
25
			$time = '<span class="time-left">'.$timetext.'</span>
26-
			data-lotteryid="'.$product->id.'" data-format="'.get_option( 'simple_lottery_countdown_format' ).'"></div>';
26+
27
			data-time="'.$counter_time.'"
28
			data-lotteryid="'.$product->get_id().'" data-format="'.get_option(
29
			'simple_lottery_countdown_format' ).'"></div>';
30
31
			if($product->is_closed()){
32
				$time = '<span class="has-finished">'.__('Lottery finished','wc_lottery').'</span>';
33
			}
34
			echo $time;
35
		}