wpgenie icon

auction start Starts Sunday, 30 July

wpgenie | PRO | 07/21/23 01:52:37 PM UTC (Edited) | 0 ⭐ | 1406 👁️ | Never ⏰ | []
PHP |

1.52 KB

|

None

|

0 👍

/

0 👎

/* custom show countdown timer in loop, future auctions have Starts Sunday, 30 July instead of countdown timer */
 
add_action( 'woocommerce_after_shop_loop_item_title','wpgenie_show_counter_in_loop',50 );
 
function wpgenie_show_counter_in_loop() {
    global $product;
 
    $time = '';
    $future_class = '';
 
    if ( ! isset( $product ) ) {
        return;
    }
    if ( 'auction' !== $product->get_type() ) {
        return;
    }
 
    $timetext = esc_html__( 'Time left', 'wc_simple_auctions' );
 
    if ( ! $product->is_started() ) {
        // $timetext     = esc_html__( 'Starting in', 'wc_simple_auctions' );
        // $counter_time = $product->get_seconds_to_auction();
 
        $future_class = ( $product->is_closed() === false ) && ( $product->is_started() === false ) ? 'future' : '';
 
        echo apply_filters( 'time_text', esc_html__( 'Starts', 'wc_simple_auctions' ), $product->get_id() ). ' ';
    
        echo date_i18n( 'l, j F', strtotime( $product->get_auction_start_time() ) ).'<br><br>'; 
    
        echo $time;
 
    } else {
        $counter_time = $product->get_seconds_remaining();
 
        $time = '<span class="time-left ">' . $timetext . '</span>
        <div class="auction-time-countdown ' . $future_class . '"
        data-time="' . esc_attr( $counter_time ) . '"
        data-auctionid="' . intval( $product->get_id() ) . '" data-format="' . esc_attr( get_option( 'simple_auctions_countdown_format' ) ) . '"></div>';
 
        if ( $product->is_closed() ) {
            $time = '<span class="has-finished">' . __( 'Auction finished', 'wc_simple_auctions' ) . '</span>';
        }
 
        echo $time;
 
    }
    
 
    
}

Comments