Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* visit us - https://wpgenie.org */
- 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 ( '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();
- } else {
- $counter_time = $product->get_seconds_remaining();
- }
- $future_class = ( $product->is_closed() === false ) && ( $product->is_started() === false ) ? 'future' : '';
- $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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement