daily pastebin goal
34%
SHARE
TWEET

Add groupbuy counter in the loop WC 3.0 +

wpgenie May 3rd, 2017 984 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('groupbuy' != $product->get_type())
  12.                 return;
  13.  
  14.             $timetext = __('Time left', 'wc_groupbuy');
  15.  
  16.             if(!$product->is_started()){
  17.                 $timetext = __('Starting in', 'wc_groupbuy');
  18.                 $counter_time = $product->get_seconds_to_groupbuy();
  19.             } else{
  20.                 $counter_time = $product->get_seconds_remaining();
  21.             }
  22.  
  23.             $time = '<span class="time-left">'.$timetext.'</span>
  24.             <div class="groupbuy-time-countdown"
  25.             data-time="'.$counter_time.'"
  26.             data-groupbuyid="'.$product->get_id().'" data-format="'.get_option(
  27.             'simple_groupbuy_countdown_format' ).'"></div>';
  28.  
  29.             if($product->is_closed()){
  30.                 $time = '<span class="has-finished">'.__('Group Buy deal finished','wc_groupbuy').'</span>';
  31.             }
  32.             echo $time;
  33.         }
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