add_action( 'woocommerce_after_shop_loop_item_title','wpgenie_show_counter_in_loop',50 );
function wpgenie_show_counter_in_loop(){
global $product;
$time = '';
if(!isset ($product))
return;
if('groupbuy' != $product->get_type())
return;
$timetext = __('Time left', 'wc_groupbuy');
if(!$product->is_started()){
$timetext = __('Starting in', 'wc_groupbuy');
$counter_time = $product->get_seconds_to_groupbuy();
} else{
$counter_time = $product->get_seconds_remaining();
}
$time = '<span class="time-left">'.$timetext.'</span>
<div class="groupbuy-time-countdown"
data-time="'.$counter_time.'"
data-groupbuyid="'.$product->get_id().'" data-format="'.get_option(
'simple_groupbuy_countdown_format' ).'"></div>';
if($product->is_closed()){
$time = '<span class="has-finished">'.__('Group Buy deal finished','wc_groupbuy').'</span>';
}
echo $time;
}
Comments