Why doesn't JavaScript code loop in content-product wordpress


in content-product.php

i have products as auction and i want show in shop page countdown timer when auction end

i write script code for countdown timer

but the script show for one product not loop for all products

    $auctionstatus = get_post_meta( $product->get_id(), 'mp_auction_status', true );
    $clientt_tz = date("Y-m-d H:i:s");
    $auctio_time_1= $_product_meta['auction_stop_time'][0];
    if ($auctionstatus == "enabled") {
        if ($auctio_time_1 >= $clientt_tz ){
    echo  "Auction end at ";

    $js_code =<<<JS
    <script language="JavaScript">
    TargetDate = "$auctio_time_1";
    ForeColor = "#009fe3";
    CountActive = true;
    CountStepper = -1;
    LeadingZero = true;
    DisplayFormat = "%%D%% D, %%H%% T, %%M%% M, %%S%% S.";
    FinishMessage = "It is finally here!";
    <script language="JavaScript" src="https://scripts.hashemian.com/js/countdown.js"></script>

    echo "<br>", $js_code;

        else {
            echo  "Auction end " ;


    } ?>

I mean, if you’re going to (badly) copy and paste a StackOverflow question and not read the answer that was given 21 hours ago…wouldnt you do better asking someone to explain the answer to you than asking the same question again?

sorry but i’m beginner on script code
that reasons i write here i want someone explain to me

What the answer you got on SO is pointing to is that the countdown script is written in such a way that it only expects 1 such clock on any given page. If you want multiple, then you’ll need to change it, or probably better yet, come up with your own version.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.