• Resolved nownobbi

    (@lukasltd)


    Hello,

    I want to display the countdown (time left) of the auction under each thumbnail of a product in the shop page.

    I created the product overview page with this short code:
    [uwa_ending_soon_auctions columns=”2″ order=”asc” hidescheduled=yes limit=”12″ paginate=”true”]

    How can I add the countdown from the product detail page to the displayed products?
    (The end date of the auction would also work)

    Theme: Astra
    WP-Version: 5.6

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hello,

    You can display countdown timer and ending date of auction product on shop page by override template file.
    Copy template file from
    Woocommerce plugin -> templates -> content-product.php
    and paste it into below path(Create folder structure as follows.)
    Root folder of active theme(Astra) -> woocommerce -> content-product.php. Add below code in this file after “woocommerce_after_shop_loop_item_title” hook and save it. It will display timer on shop page.

    <?php
    global $post, $product, $woocommerce, $wpdb;
    $product_id = $product->get_id();

    if(($product->is_woo_ua_closed() === FALSE ) and ($product->is_woo_ua_started() === TRUE )) : ?>

    <div class=”uwa_auction_time” id=”uwa_auction_countdown”>

    <?php _e(‘Time Left:’, ‘woo_ua’); ?>

    <div class=”uwa-main-auction-product uwa_auction_product_countdown” data-time=” <?php echo $product->get_woo_ua_remaining_seconds() ?> ” data-auction-id=” <?php
    echo esc_attr( $product_id ); ?> ” data-format=” <?php echo get_option(
    ‘woo_ua_auctions_countdown_format’ ) ?> “>
    </div>
    </div>
    <p class=”uwa_auction_end_time”>
    <?php _e(‘Ending On:’, ‘woo_ua’); ?>
    <?php echo date_i18n( get_option( ‘date_format’ ), strtotime( $product->get_woo_ua_auctions_end_time() )); ?>
    <?php echo date_i18n( get_option( ‘time_format’ ), strtotime( $product->get_woo_ua_auctions_end_time() )); ?>
    </p>

    <?php endif; ?>

    Thank You

    Plugin Author Nitesh

    (@nitesh_singh)

    This ticket seems to be resolved. If there are any questions, please let us know.

    @payalrajyaguru

    Please can you help me? I am using Divi child theme and I did exactly what you wrote, and my live auction site disappeared.

    What should I do to make it work?

    Thank you!

    Thread Starter nownobbi

    (@lukasltd)

    Hello @payalrajyaguru and @nitesh_singh

    thank you for your quick reply. I did exactly as you told me and it also didn’t work for me.

    This is the content-product.php from Asta:

    `<?php
    /**
    * The template for displaying product content within loops
    *
    * This template can be overridden by copying it to yourtheme/woocommerce/content-product.php.
    *
    * HOWEVER, on occasion WooCommerce will need to update template files and you
    * (the theme developer) will need to copy the new files to your theme to
    * maintain compatibility. We try to do this as little as possible, but it does
    * happen. When this occurs the version of the template file will be bumped and
    * the readme will list any important changes.
    *
    * @see https://docs.woocommerce.com/document/template-structure/
    * @package WooCommerce\Templates
    * @version 3.6.0
    */

    defined( ‘ABSPATH’ ) || exit;

    global $product;

    // Ensure visibility.
    if ( empty( $product ) || ! $product->is_visible() ) {
    return;
    }
    ?>
    <li <?php wc_product_class( ”, $product ); ?>>
    <?php
    /**
    * Hook: woocommerce_before_shop_loop_item.
    *
    * @hooked woocommerce_template_loop_product_link_open – 10
    */
    do_action( ‘woocommerce_before_shop_loop_item’ );

    /**
    * Hook: woocommerce_before_shop_loop_item_title.
    *
    * @hooked woocommerce_show_product_loop_sale_flash – 10
    * @hooked woocommerce_template_loop_product_thumbnail – 10
    */
    do_action( ‘woocommerce_before_shop_loop_item_title’ );

    /**
    * Hook: woocommerce_shop_loop_item_title.
    *
    * @hooked woocommerce_template_loop_product_title – 10
    */
    do_action( ‘woocommerce_shop_loop_item_title’ );

    /**
    * Hook: woocommerce_after_shop_loop_item_title.
    *
    * @hooked woocommerce_template_loop_rating – 5
    * @hooked woocommerce_template_loop_price – 10
    */
    do_action( ‘woocommerce_after_shop_loop_item_title’ );

    /**
    * Hook: woocommerce_after_shop_loop_item.
    *
    * @hooked woocommerce_template_loop_product_link_close – 5
    * @hooked woocommerce_template_loop_add_to_cart – 10
    */
    do_action( ‘woocommerce_after_shop_loop_item’ );
    ?>

    Where exactly should I paste the above code in order to make it work?

    Hello,

    We’ve added custom code in the content-product.php template file below. We have tested this code on our test server. This code works properly with Astra(child theme) without error. Add this content-product.php file in below path.
    Root folder of active theme -> woocommerce -> content-product.php.

    <?php
    /**
     * The template for displaying product content within loops
     *
     * This template can be overridden by copying it to yourtheme/woocommerce/content-product.php.
     *
     * HOWEVER, on occasion WooCommerce will need to update template files and you
     * (the theme developer) will need to copy the new files to your theme to
     * maintain compatibility. We try to do this as little as possible, but it does
     * happen. When this occurs the version of the template file will be bumped and
     * the readme will list any important changes.
     *
     * @see     https://docs.woocommerce.com/document/template-structure/
     * @package WooCommerce\Templates
     * @version 3.6.0
     */
    defined( 'ABSPATH' ) || exit;
    global $product;
    // Ensure visibility.
    if ( empty( $product ) || ! $product->is_visible() ) {
    	return;
    }
    ?>
    <li <?php wc_product_class( '', $product ); ?>>
    	<?php
    	/**
    	 * Hook: woocommerce_before_shop_loop_item.
    	 *
    	 * @hooked woocommerce_template_loop_product_link_open - 10
    	 */
    	do_action( 'woocommerce_before_shop_loop_item' );
    	/**
    	 * Hook: woocommerce_before_shop_loop_item_title.
    	 *
    	 * @hooked woocommerce_show_product_loop_sale_flash - 10
    	 * @hooked woocommerce_template_loop_product_thumbnail - 10
    	 */
    	do_action( 'woocommerce_before_shop_loop_item_title' );
    	/**
    	 * Hook: woocommerce_shop_loop_item_title.
    	 *
    	 * @hooked woocommerce_template_loop_product_title - 10
    	 */
    	do_action( 'woocommerce_shop_loop_item_title' );
    	/**
    	 * Hook: woocommerce_after_shop_loop_item_title.
    	 *
    	 * @hooked woocommerce_template_loop_rating - 5
    	 * @hooked woocommerce_template_loop_price - 10
    	 */
    	do_action( 'woocommerce_after_shop_loop_item_title' );
    	global $post, $product, $woocommerce, $wpdb;
    	$product_id = $product->get_id();
    	if(($product->is_woo_ua_closed() === FALSE ) and ($product->is_woo_ua_started() === TRUE )) : ?>
    	<div class="uwa_auction_time" id="uwa_auction_countdown">
    	<?php _e('Time Left:', 'woo_ua'); ?>
    	<div class="uwa-main-auction-product uwa_auction_product_countdown" data-time=" <?php echo $product->get_woo_ua_remaining_seconds() ?> " data-auction-id=" <?php
    	echo esc_attr( $product_id ); ?> " data-format=" <?php echo get_option(
    	'woo_ua_auctions_countdown_format' ) ?> ">
    	</div>
    	</div>
    	<p class="uwa_auction_end_time">
    	<?php _e('Ending On:', 'woo_ua'); ?>
    	<?php echo date_i18n( get_option( 'date_format' ), strtotime( $product->get_woo_ua_auctions_end_time() )); ?>
    	<?php echo date_i18n( get_option( 'time_format' ), strtotime( $product->get_woo_ua_auctions_end_time() )); ?>
    	</p>
    	<?php endif;
    	/**
    	 * Hook: woocommerce_after_shop_loop_item.
    	 *
    	 * @hooked woocommerce_template_loop_product_link_close - 5
    	 * @hooked woocommerce_template_loop_add_to_cart - 10
    	 */
    	do_action( 'woocommerce_after_shop_loop_item' );
    	?>
    </li>

    This code will work for your site.

    Thread Starter nownobbi

    (@lukasltd)

    Hello @payalrajyaguru and @nitesh_singh

    thank you again for your quick reply.

    I added the modified content-product.php file in the path, but it still did not work.

    The webiste only shows the picture of the first product and underneath it says:
    “There was a critical error on your website”

    I hope you can help me with this problem.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Countdown on Live Auction Page’ is closed to new replies.