SHARE
TWEET

auctions show counter in the loop

wpgenie Mar 13th, 2018 (edited) 3,940 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.     global $product;
  5.  
  6.     $time = '';
  7.  
  8.     if ( ! isset( $product ) ) {
  9.         return;
  10.     }
  11.     if ( 'auction' !== $product->get_type() ) {
  12.         return;
  13.     }
  14.  
  15.     $timetext = esc_html__( 'Time left', 'wc_simple_auctions' );
  16.  
  17.     if ( ! $product->is_started() ) {
  18.         $timetext     = esc_html__( 'Starting in', 'wc_simple_auctions' );
  19.         $counter_time = $product->get_seconds_to_auction();
  20.     } else {
  21.         $counter_time = $product->get_seconds_remaining();
  22.     }
  23.     $future_class = ( $product->is_closed() === false ) && ( $product->is_started() === false ) ? 'future' : '';
  24.  
  25.     $time = '<span class="time-left ">' . $timetext . '</span>
  26.     <div class="auction-time-countdown ' . $future_class . '"
  27.     data-time="' . esc_attr( $counter_time ) . '"
  28.     data-auctionid="' . intval( $product->get_id() ) . '" data-format="' . esc_attr( get_option( 'simple_auctions_countdown_format' ) ) . '"></div>';
  29.  
  30.     if ( $product->is_closed() ) {
  31.         $time = '<span class="has-finished">' . __( 'Auction finished', 'wc_simple_auctions' ) . '</span>';
  32.     }
  33.  
  34.     echo $time;
  35. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top