Advertisement
wpgenie

auction start Starts Sunday, 30 July

Jul 21st, 2023 (edited)
852
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.52 KB | None | 0 0
  1. /* custom show countdown timer in loop, future auctions have Starts Sunday, 30 July instead of countdown timer */
  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.     global $product;
  7.  
  8.     $time = '';
  9.     $future_class = '';
  10.  
  11.     if ( ! isset( $product ) ) {
  12.         return;
  13.     }
  14.     if ( 'auction' !== $product->get_type() ) {
  15.         return;
  16.     }
  17.  
  18.     $timetext = esc_html__( 'Time left', 'wc_simple_auctions' );
  19.  
  20.     if ( ! $product->is_started() ) {
  21.         // $timetext     = esc_html__( 'Starting in', 'wc_simple_auctions' );
  22.         // $counter_time = $product->get_seconds_to_auction();
  23.  
  24.         $future_class = ( $product->is_closed() === false ) && ( $product->is_started() === false ) ? 'future' : '';
  25.  
  26.         echo apply_filters( 'time_text', esc_html__( 'Starts', 'wc_simple_auctions' ), $product->get_id() ). ' ';
  27.    
  28.         echo date_i18n( 'l, j F', strtotime( $product->get_auction_start_time() ) ).'<br><br>';
  29.    
  30.         echo $time;
  31.  
  32.     } else {
  33.         $counter_time = $product->get_seconds_remaining();
  34.  
  35.         $time = '<span class="time-left ">' . $timetext . '</span>
  36.         <div class="auction-time-countdown ' . $future_class . '"
  37.         data-time="' . esc_attr( $counter_time ) . '"
  38.         data-auctionid="' . intval( $product->get_id() ) . '" data-format="' . esc_attr( get_option( 'simple_auctions_countdown_format' ) ) . '"></div>';
  39.  
  40.         if ( $product->is_closed() ) {
  41.             $time = '<span class="has-finished">' . __( 'Auction finished', 'wc_simple_auctions' ) . '</span>';
  42.         }
  43.  
  44.         echo $time;
  45.  
  46.     }
  47.    
  48.  
  49.    
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement