Incérmentation id div

Pour toutes les discussions javascript, jQuery et autres frameworks
Répondre
sanka0579
Messages : 6
Enregistré le : 02 févr. 2023, 13:52

Incérmentation id div

Message par sanka0579 » 20 juin 2023, 22:51

Bonjour,

Je rencontre un soucis, je vais essayé d'être clair dans mon explication:

Je souhaite intégrer un compte à rebours individuel pour chaque annonce d'enchère (remps restant).

Pour cela j'essaie d'incrémenter in ID de div dans une boucle. Le problème est que l'incrémentation ne reste pas fixe, mais varie entre plusieurs chiffres.

Je vous remercie d'avance.

Voici le code:

Code : Tout sélectionner

<script>
            var x = [];
        </script>
        
        <?php       

                                $id_annonce = 1;

                                foreach($annonces_en_cours as $annonce)
                                {   
                                    $id_annonce++;
                                    // Infos author
                                    $author_id = get_post($annonce->ID)->post_author;
                                    $user_info = get_userdata($author_id);
                                    $user_impl = implode(', ', $user_info->roles);

                                    // Infos annonce
                                    $all_post_meta = get_post_meta($annonce->ID);
                                    $get_title = get_the_title($annonce->ID);                                    
                                    $auction_type = get_the_terms($annonce->ID, 'vehica_19636');
                                    $auction_type_slug = $auction_type[0]->slug;                                      
                                    $annonce_auction_list = get_post_meta($annonce->ID, 'auction_list');
                                    $annonce_auction_status = get_post_meta($annonce->ID, 'auction_status', true);

                                    // Infos autheur
                                    $author_id = get_the_id($annonce);

                                    // Info du véhicule
                                    $get_mark = get_post_meta($annonce->ID, 'vehica_39814', true);
                                    $get_model = get_post_meta($annonce->ID, 'vehica_39815', true);
                                    $get_carburant = get_the_terms($annonce->ID, 'vehica_48489');
                                    $get_boite = get_the_terms($annonce->ID, 'vehica_48484');
                                    $get_km = get_post_meta($annonce->ID, 'vehica_48173', true);                                   
                                    $images_gallery = get_post_meta($annonce->ID, 'vehica_19246');
                                    $first_img_src = wp_get_attachment_image_src($images_gallery[0], 'medium');
                                    $link_to_annonce = get_permalink($annonce->ID);
                                    $get_first_imm = get_post_meta($annonce->ID, 'vehica_19190', true);
                                    $reserve_price = get_post_meta($annonce->ID, 'vehica_currency_19362_2316');

                                    // Infos date
                                    date_default_timezone_set('Europe/Paris');

                                    $start_date = get_post_meta($annonce->ID, 'vehica_20836', true);
                                    $start_hour = get_post_meta($annonce->ID, 'vehica_20856', true);
                                    $start_date_hour = $start_date . ' ' . $start_hour;

                                    $end_date = strtotime($start_date_hour . '+ 1 days');

                                    // Infos si autres annonces
                                    $content = wp_trim_words(get_post_field('post_content', $annonce->ID), 5, '...'); 

                                                                    
                                    // Reserve
                                    if(intval($reserve_price[0]) < 5001)
                                    {
                                            $start_price = intval($reserve_price[0]) * (1 -0.5);
                                        }
                                        else if(intval($reserve_price[0]) < 10001)
                                        {
                                            $start_price = intval($reserve_price[0]) * (1 -0.35);
                                        }
                                        else if(intval($reserve_price[0]) < 15001)
                                        {
                                            $start_price = intval($reserve_price[0]) * (1 -0.3);
                                        }
                                        else if(intval($reserve_price[0]) < 25001)
                                        {
                                            $start_price = intval($reserve_price[0]) * (1 -0.15);
                                        }
                                        else if(intval($reserve_price[0]) < 35001)
                                        {
                                            $start_price = intval($reserve_price[0]) * (1 -0.15);
                                        }
                                        else if(intval($reserve_price[0]) < 45001)
                                        {
                                            $start_price = intval($reserve_price[0]) * (1 -0.1);
                                        }
                                        else if(intval($reserve_price[0]) < 55001)
                                        {
                                            $start_price = intval($reserve_price[0]) * (1 -0.1);
                                        }
                                        else if(intval($reserve_price[0]) < 65001)
                                        {
                                            $start_price = intval($reserve_price[0]) * (1 -0.1);
                                        }
                                        else if(intval($reserve_price[0]) < 75001)
                                        {
                                            $start_price = intval($reserve_price[0]) * (1 -0.1);
                                        }
                                        else if(intval($reserve_price[0]) < 85001)
                                        {
                                            $start_price = intval($reserve_price[0]) * (1 -0.1);
                                        }
                                        else if(intval($reserve_price[0]) < 95001)
                                        {
                                            $start_price = intval($reserve_price[0]) * (1 -0.1);
                                        }
                                        else if(intval($reserve_price[0]) < 125001)
                                        {
                                            $start_price = intval($reserve_price[0]) * (1 -0.1);
                                        }
                                        else if(intval($reserve_price[0]) > 125001)
                                        {
                                            $start_price = intval($reserve_price[0]) * (1 -0.1);
                                        }
                                        
                                        if($auction_type_slug == "autres-annonces")
                                        {
                                            $start_price = intval($reserve_price[0]) * (1 - 0.3); 
                                            $step_price = 10; 
                                            $max_price = intval($reserve_price[0]) + 1000; 
                                    }

                                    if( !empty($annonce_auction_list))
                                    {
                                        $get_current_last_auction = end($annonce_auction_list[0]); 
                                        $get_actual_auction_price = number_format($get_current_last_auction['auctionner_price'], 0, ".", "'");
                                    }
                                    

                                    if($annonce_auction_status == 'demarrer')
                                    {
                                        echo'  
                                        
                                        <li class="afs-list-item list--list-item afs-car-' . $annonce->ID . '" data-id="' . $annonce->ID . '" data-gender="' . $auction_type_slug . '">                                        
                                        
                                            <div class="auction_end_date" style="display: none;">' . $end_date . '</div>
                                            <div class="get_home_auction_list_item_zone_text_hidden_end_date" style="display: none;">' . $end_date . '</div>
                                            <div class="get_home_auction_list_item_zone_text_date" style="display: none;">' . $start_date_hour . '</div>
                                            <div class="name" style="height: 1px;">' . $get_mark . '</div>
                                            <div class="address" style="height: 1px;">' . $user_impl . '</div>

                                            <div class="afs-card__inner">

                                                <a href="' . $link_to_annonce . '" class="afs-card-link"></a>         

                                                <div class="afs-list-item__image-bg" >
                                                    <div class="afs_list_item__image">
                                                        <img src="' . $first_img_src[0] . '" data-sizes="auto" alt="' . $get_title . '" class="lazyautosizes lazyloaded" sizes="248px" srcset="">                                                            
                                                    </div>
                                                </div>  

                                                <div style="display: flex; justify-content: space-between; background: #F37021; border-bottom: 1px solid #F37021; padding: 1% 0;">'; ?>

                                                    <script>
                                                        <?php 
                                                            $dateTime = $end_date;
                                                            $getDateTime = date("F d, Y H:i:s", $dateTime);
                                                        ?>
                                                        var countDownDate = new Date("<?php echo "$getDateTime"; ?>").getTime();
                                                        
                                                        // Update the count down every 1 second
                                                        
                                                        x[<?=$id_annonce?>] =  setInterval(function() {
                                                            var now = new Date().getTime();
                                                            // Find the distance between now an the count down date
                                                            var distance = countDownDate - now;                
                                                            // Time calculations for days, hours, minutes and seconds
                                                            var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
                                                            var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
                                                            var seconds = Math.floor((distance % (1000 * 60)) / 1000);
                                                            // Output the result in an element with id="counter"11
                                                            if(distance > 0)
                                                            {
                                                                $('.afs_card_cardcounter').html(
                                                                "<ul id='afs_card_counter_'<? $id_annonce; ?>' class='afs_counter_card_number'>" +
                                                                    "<li>" + "<i class='fas fa-clock'></i> " + "</li>" +
                                                                    "<li>" + hours + "<span>" + " H" + "</span>" + "</li>" +
                                                                    "<li>" + minutes + "<span>" + " Min " + "</span>" + "</li>" +
                                                                    "<li>" + seconds + "<span>" + " Sec " + "</span>" + "</li>" +
                                                                "</ul>");     
                                                            }
                                                            else
                                                            {
                                                                $('.afs_card_cardcounter').html(
                                                                "<ul id='afs_card_counter_'<? $id_annonce; ?>' class='afs_counter_card_number'>" +
                                                                    "<li class='afs_counter_ended'>" + "<i class='fas fa-clock'></i> " + "Enchère terminée" + "</li>" +
                                                                "</ul>"
                                                                );
                                                            }                   
                                                        }, 1000);
                                                    </script>
                                                    
                                                    <?php

                                                    echo '

                                                    <div class="afs_card_cardcounter afs_card_cardcounter_in_progress_counter_background"></div>';                                                       

                                                    if(!empty($annonce_auction_list)) 
                                                    {
                                                        $get_current_last_auction = end($annonce_auction_list[0]); 
                                                        $get_actual_auction_price = number_format($get_current_last_auction['auctionner_price'], 0, ".", "'");
                                                    
                                                        echo '<div class="afs-card__image__seller" style="font-weight: 600;"><i class="fas fa-gavel" style="margin-right: 5px;"></i>' . $get_actual_auction_price  . '.- CHF</div>';
                                                    }

                                                    echo'

                                                </div>
                                                
                                                <div class="afs-list-item__content">
                                                
                                                    <div style="display: flex; align-items: baseline; justify-content: space-between;">
                                                        <a href="' . $link_to_annonce . '"title="' . $get_title . '"class="afs-list-item__name">' . $get_mark . ' ' . $get_model . '</a>                                                                                                    
                                                    </div>
                                                    
                                                    <div class="afs-card_price">Prix de départ : ';
                                                    
                                                        if($auction_type_slug == 'autres-annonces' && $start_price < 1000)
                                                        {
                                                            echo number_format(ceil($start_price/10)*10, 0, ".", "'") . ' CHF';
                                                        }
                                                        else
                                                        {
                                                            echo number_format(ceil($start_price/100)*100, 0, ".", "'") . ' CHF';
                                                        }

                                                        echo '

                                                    </div>
                                                                                        
                                                    <div class="afs-card-card__separator"></div>';

                                                    if($auction_type_slug == 'autres-annonces')
                                                    {
                                                        echo '<div class="afs-list-item-card__info">' . $content . '</div>';
                                                    }
                                                    else
                                                    {
                                                        echo'
                                                            
                                                        <div class="afs-list-item-card__info">';

                                                            if(!empty($get_first_imm))
                                                            {
                                                                echo '<div class="afs-list-item__info__single">' . $get_first_imm . '</div>';
                                                            }
                                                            if(!empty($get_km))
                                                            {
                                                                echo '<div class="afs-list-item__info__single">' . number_format($get_km, 0, ".", "'") . ' Km</div>';
                                                            }
                                                            if(!empty($get_boite))
                                                            {
                                                                echo '<div class="afs-list-item__info__single">' . $get_boite[0]->name . '</div>';
                                                            }
                                                            /*if(!empty($get_carburant))
                                                            {
                                                                echo '<div class="afs-list-item__info__single">' . $get_carburant[0]->name . '</div>';
                                                            }*/
                                                            
                                                            echo'       

                                                        </div>';   
                                                    }
                                                    
                                                    echo '
                                                
                                                </div>                          
                                                        
                                            </div>                                             

                                        </li>';
                                    }
                                }

                            ?>  
        

Avatar du membre
webmaster
Administrateur du site
Messages : 578
Enregistré le : 28 févr. 2017, 15:19

Re: Incérmentation id div

Message par webmaster » 21 juin 2023, 12:06

Bonjour,

Ca serait plus facile de répondre avec le code HTML généré par le script PHP
La je ne peux pas trop répondre sans les données d'exemple
TJS : 25 ans et mon livre Tout JavaScript chez Dunod
https://www.toutjavascript.com/livre/index.php

sanka0579
Messages : 6
Enregistré le : 02 févr. 2023, 13:52

Re: Incérmentation id div

Message par sanka0579 » 21 juin 2023, 14:11

Hello,

Merci pour la réponse.

Voici le code complet:

Code : Tout sélectionner

<?php   

/* Shortcode - enchères en cours */
function afs_home_page_auctions_func()
{
    /* SHORTCODE START **************************************************** */ 
      
    /* Récupération des annonces en cours*/
    $args = array
    (
        'post_type'        => 'vehica_car',
        'posts_per_page'   => -1,
        'cache_results'  => false,
        'update_post_meta_cache' => false, 
        'update_post_term_cache' => false,
        'order' => 'DESC',   
        'orderby' => array(
            'date' => 'DESC',
            'auction_list' => 'DESC',
        ),
        'tax_query' => array(
            array (
                'taxonomy' => 'vehica_19636',
                'field' => 'slug',
                'terms' => array( 'voitures', 'motocycles', 'vehicules-utilitaires', 'autres-annonces'),
            )
        ), 
        'meta_query' => array( 
            array(
                'key' => 'auction_status',
                'value' => 'demarrer', 
                'compare' => 'IN', 
            ),  
        ),
       
    );

    $start_query = new WP_Query( $args );
    $annonces_en_cours = $start_query->posts; 

    ob_start(); ?>

        <script>var x = [];</script>

        <?php

        if (!empty($annonces_en_cours))
        { ?>
                
            <div class="container">
                <div class="row">
                    <div id="users">
                        <div class="filter-group row">
                            
                            <div class="filter-title">
                                <p>Filtrer</p>
                            </div>
                            <div class="form-group">
                                <div class="radio-inline">
                                    <label>
                                        <input class="filter-all" type="radio" value="all" name="gender" id="gender-all" checked /> Tout
                                    </label>
                                </div>
                                <div class="radio-inline">
                                    <label>
                                        <input class="filter" type="radio" value="voitures" name="gender" id="gender-car" /> Voitures
                                    </label>
                                </div>
                                <div class="radio-inline">
                                    <label>
                                        <input class="filter" type="radio" value="vehicules-utilitaires" name="gender" id="vehicules-utilitaires" /> Utilitaires
                                    </label>
                                </div>
                                <div class="radio-inline">
                                    <label>
                                        <input class="filter" type="radio" value="motocycles" name="gender" id="gender-motos" /> Motos
                                    </label>
                                </div>
                                <div class="radio-inline">
                                    <label>
                                        <input class="filter" type="radio" value="autres-annonces" name="gender" id="gender-other" /> Autres
                                    </label>
                                </div>
                                <div class="radio-inline">
                                    <label>
                                        <input class="filter" type="radio" value="vehica_business_role" name="address" id="business-role" /> Pros
                                    </label>
                                </div>
                                <div class="radio-inline">
                                    <label>
                                        <input class="filter" type="radio" value="vehica_private_role" name="address" id="private-role" /> Privés
                                    </label>
                                </div>
                            </div>
                            <label class="filter-title" style="margin-right: 2em; text-align: center">Rechercher par marque
                                <input style="margin-left: 0.5em;" type="text" class="search form-control" placeholder="Exemple: Audi" />
                            </label>
                            <div class="form-group col-xs-12 col-sm-12">
                                <button class="btn btn-danger" onclick="resetList();">Annuler</button>
                            </div>
                        </div>

                        <ul class="list afs-list">
                        
                            <?php       

                                $id_annonce = 1;

                                foreach($annonces_en_cours as $annonce)
                                {   
                                    $id_annonce++;
                                    // Infos author
                                    $author_id = get_post($annonce->ID)->post_author;
                                    $user_info = get_userdata($author_id);
                                    $user_impl = implode(', ', $user_info->roles);

                                    // Infos annonce
                                    $all_post_meta = get_post_meta($annonce->ID);
                                    $get_title = get_the_title($annonce->ID);                                    
                                    $auction_type = get_the_terms($annonce->ID, 'vehica_19636');
                                    $auction_type_slug = $auction_type[0]->slug;                                      
                                    $annonce_auction_list = get_post_meta($annonce->ID, 'auction_list');
                                    $annonce_auction_status = get_post_meta($annonce->ID, 'auction_status', true);

                                    // Infos autheur
                                    $author_id = get_the_id($annonce);

                                    // Info du véhicule
                                    $get_mark = get_post_meta($annonce->ID, 'vehica_39814', true);
                                    $get_model = get_post_meta($annonce->ID, 'vehica_39815', true);
                                    $get_carburant = get_the_terms($annonce->ID, 'vehica_48489');
                                    $get_boite = get_the_terms($annonce->ID, 'vehica_48484');
                                    $get_km = get_post_meta($annonce->ID, 'vehica_48173', true);                                   
                                    $images_gallery = get_post_meta($annonce->ID, 'vehica_19246');
                                    $first_img_src = wp_get_attachment_image_src($images_gallery[0], 'medium');
                                    $link_to_annonce = get_permalink($annonce->ID);
                                    $get_first_imm = get_post_meta($annonce->ID, 'vehica_19190', true);
                                    $reserve_price = get_post_meta($annonce->ID, 'vehica_currency_19362_2316');

                                    // Infos date
                                    date_default_timezone_set('Europe/Paris');

                                    $start_date = get_post_meta($annonce->ID, 'vehica_20836', true);
                                    $start_hour = get_post_meta($annonce->ID, 'vehica_20856', true);
                                    $start_date_hour = $start_date . ' ' . $start_hour;

                                    $end_date = strtotime($start_date_hour . '+ 1 days');

                                    // Infos si autres annonces
                                    $content = wp_trim_words(get_post_field('post_content', $annonce->ID), 5, '...'); 

                                                                    
                                    // Reserve
                                    if(intval($reserve_price[0]) < 5001)
                                    {
                                            $start_price = intval($reserve_price[0]) * (1 -0.5);
                                        }
                                        else if(intval($reserve_price[0]) < 10001)
                                        {
                                            $start_price = intval($reserve_price[0]) * (1 -0.35);
                                        }
                                        else if(intval($reserve_price[0]) < 15001)
                                        {
                                            $start_price = intval($reserve_price[0]) * (1 -0.3);
                                        }
                                        else if(intval($reserve_price[0]) < 25001)
                                        {
                                            $start_price = intval($reserve_price[0]) * (1 -0.15);
                                        }
                                        else if(intval($reserve_price[0]) < 35001)
                                        {
                                            $start_price = intval($reserve_price[0]) * (1 -0.15);
                                        }
                                        else if(intval($reserve_price[0]) < 45001)
                                        {
                                            $start_price = intval($reserve_price[0]) * (1 -0.1);
                                        }
                                        else if(intval($reserve_price[0]) < 55001)
                                        {
                                            $start_price = intval($reserve_price[0]) * (1 -0.1);
                                        }
                                        else if(intval($reserve_price[0]) < 65001)
                                        {
                                            $start_price = intval($reserve_price[0]) * (1 -0.1);
                                        }
                                        else if(intval($reserve_price[0]) < 75001)
                                        {
                                            $start_price = intval($reserve_price[0]) * (1 -0.1);
                                        }
                                        else if(intval($reserve_price[0]) < 85001)
                                        {
                                            $start_price = intval($reserve_price[0]) * (1 -0.1);
                                        }
                                        else if(intval($reserve_price[0]) < 95001)
                                        {
                                            $start_price = intval($reserve_price[0]) * (1 -0.1);
                                        }
                                        else if(intval($reserve_price[0]) < 125001)
                                        {
                                            $start_price = intval($reserve_price[0]) * (1 -0.1);
                                        }
                                        else if(intval($reserve_price[0]) > 125001)
                                        {
                                            $start_price = intval($reserve_price[0]) * (1 -0.1);
                                        }
                                        
                                        if($auction_type_slug == "autres-annonces")
                                        {
                                            $start_price = intval($reserve_price[0]) * (1 - 0.3); 
                                            $step_price = 10; 
                                            $max_price = intval($reserve_price[0]) + 1000; 
                                    }

                                    if( !empty($annonce_auction_list))
                                    {
                                        $get_current_last_auction = end($annonce_auction_list[0]); 
                                        $get_actual_auction_price = number_format($get_current_last_auction['auctionner_price'], 0, ".", "'");
                                    }
                                    

                                    if($annonce_auction_status == 'demarrer')
                                    {
                                        echo'  
                                        
                                        <li class="afs-list-item list--list-item afs-car-' . $annonce->ID . '" data-id="' . $annonce->ID . '" data-gender="' . $auction_type_slug . '">                                        
                                        
                                            <div class="auction_end_date" style="display: none;">' . $end_date . '</div>
                                            <div class="get_home_auction_list_item_zone_text_hidden_end_date" style="display: none;">' . $end_date . '</div>
                                            <div class="get_home_auction_list_item_zone_text_date" style="display: none;">' . $start_date_hour . '</div>
                                            <div class="name" style="height: 1px;">' . $get_mark . '</div>
                                            <div class="address" style="height: 1px;">' . $user_impl . '</div>

                                            <div class="afs-card__inner">

                                                <a href="' . $link_to_annonce . '" class="afs-card-link"></a>         

                                                <div class="afs-list-item__image-bg" >
                                                    <div class="afs_list_item__image">
                                                        <img src="' . $first_img_src[0] . '" data-sizes="auto" alt="' . $get_title . '" class="lazyautosizes lazyloaded" sizes="248px" srcset="">                                                            
                                                    </div>
                                                </div>  

                                                <div style="display: flex; justify-content: space-between; background: #F37021; border-bottom: 1px solid #F37021; padding: 1% 0;">'; ?>

                                                    <script>
                                                        <?php 
                                                            $dateTime = $end_date;
                                                            $getDateTime = date("F d, Y H:i:s", $dateTime);
                                                        ?>
                                                        var countDownDate = new Date("<?php echo "$getDateTime"; ?>").getTime();
                                                        // Update the count down every 1 second
                                                        
                                                        x[<?= $id_annonce ?>] =  setInterval(function() {
                                                            var now = new Date().getTime();
                                                            // Find the distance between now an the count down date
                                                            var distance = countDownDate - now;                
                                                            // Time calculations for days, hours, minutes and seconds
                                                            var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
                                                            var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
                                                            var seconds = Math.floor((distance % (1000 * 60)) / 1000);
                                                            // Output the result in an element with id="counter"11
                                                            if(distance > 0)
                                                            {
                                                                $('.afs_card_cardcounter').html(
                                                                "<ul id='afs_card_counter_<? echo $id_annonce ?>' class='afs_counter_card_number'>" +
                                                                    "<li>" + "<i class='fas fa-clock'></i> " + "</li>" +
                                                                    "<li>" + hours + "<span>" + " H" + "</span>" + "</li>" +
                                                                    "<li>" + minutes + "<span>" + " Min " + "</span>" + "</li>" +
                                                                    "<li>" + seconds + "<span>" + " Sec " + "</span>" + "</li>" +
                                                                "</ul>");     
                                                            }
                                                            else
                                                            {
                                                                $('.afs_card_cardcounter').html(
                                                                "<ul id='afs_card_counter_<? echo $id_annonce ?>' class='afs_counter_card_number'>" +
                                                                    "<li class='afs_counter_ended'>" + "<i class='fas fa-clock'></i> " + "Enchère terminée" + "</li>" +
                                                                "</ul>"
                                                                );
                                                            }                   
                                                        }, 1000);
                                                    </script>
                                                    
                                                    <?php

                                                    echo '

                                                    <div class="afs_card_cardcounter afs_card_cardcounter_in_progress_counter_background"></div>';                                                       

                                                    if(!empty($annonce_auction_list)) 
                                                    {
                                                        $get_current_last_auction = end($annonce_auction_list[0]); 
                                                        $get_actual_auction_price = number_format($get_current_last_auction['auctionner_price'], 0, ".", "'");
                                                    
                                                        echo '<div class="afs-card__image__seller" style="font-weight: 600;"><i class="fas fa-gavel" style="margin-right: 5px;"></i>' . $get_actual_auction_price  . '.- CHF</div>';
                                                    }

                                                    echo'

                                                </div>
                                                
                                                <div class="afs-list-item__content">
                                                
                                                    <div style="display: flex; align-items: baseline; justify-content: space-between;">
                                                        <a href="' . $link_to_annonce . '"title="' . $get_title . '"class="afs-list-item__name">' . $get_mark . ' ' . $get_model . '</a>                                                                                                    
                                                    </div>
                                                    
                                                    <div class="afs-card_price">Prix de départ : ';
                                                    
                                                        if($auction_type_slug == 'autres-annonces' && $start_price < 1000)
                                                        {
                                                            echo number_format(ceil($start_price/10)*10, 0, ".", "'") . ' CHF';
                                                        }
                                                        else
                                                        {
                                                            echo number_format(ceil($start_price/100)*100, 0, ".", "'") . ' CHF';
                                                        }

                                                        echo '

                                                    </div>
                                                                                        
                                                    <div class="afs-card-card__separator"></div>';

                                                    if($auction_type_slug == 'autres-annonces')
                                                    {
                                                        echo '<div class="afs-list-item-card__info">' . $content . '</div>';
                                                    }
                                                    else
                                                    {
                                                        echo'
                                                            
                                                        <div class="afs-list-item-card__info">';

                                                            if(!empty($get_first_imm))
                                                            {
                                                                echo '<div class="afs-list-item__info__single">' . $get_first_imm . '</div>';
                                                            }
                                                            if(!empty($get_km))
                                                            {
                                                                echo '<div class="afs-list-item__info__single">' . number_format($get_km, 0, ".", "'") . ' Km</div>';
                                                            }
                                                            if(!empty($get_boite))
                                                            {
                                                                echo '<div class="afs-list-item__info__single">' . $get_boite[0]->name . '</div>';
                                                            }
                                                            /*if(!empty($get_carburant))
                                                            {
                                                                echo '<div class="afs-list-item__info__single">' . $get_carburant[0]->name . '</div>';
                                                            }*/
                                                            
                                                            echo'       

                                                        </div>';   
                                                    }
                                                    
                                                    echo '
                                                
                                                </div>                          
                                                        
                                            </div>                                             

                                        </li>';
                                    }
                                }

                            ?>                   
                        </ul>
                        <div class="no-result">Aucun résultat ne correspond à votre recherche</div>  
                        <ul class="pagination"></ul>  
                    </div>
                </div>
            </div>
                    
            <?php
            
        }
        else
        {
            echo '<h1>Il n\'y à pas d\'enchères pour le moment</h1>';
        }

    return ob_get_clean();

    /* SHORTCODE END **************************************************** */
}
add_shortcode('afs_home_page_auctions', 'afs_home_page_auctions_func');
Le site: encheres24.ch

Merci d'avance

Avatar du membre
webmaster
Administrateur du site
Messages : 578
Enregistré le : 28 févr. 2017, 15:19

Re: Incérmentation id div

Message par webmaster » 21 juin 2023, 15:13

Ok, je vois le problème
Mais je n'ai pas de solution immédiate pour résoudre

Dans les scripts, il y a :
$('.afs_card_cardcounter').html("<ul id='afs_card_counter_3' ....

Cela modifie tous les elements de classe css afs_card_cardcounter
Pour cibler, le bon, il faut remplacer la génération du html pour arriver à dire :
$('.afs_card_counter_xxxx').html("<ul class='afs_card_counter' .... avec xxxx qui augmente à chaque case d'annonce
TJS : 25 ans et mon livre Tout JavaScript chez Dunod
https://www.toutjavascript.com/livre/index.php

sanka0579
Messages : 6
Enregistré le : 02 févr. 2023, 13:52

Re: Incérmentation id div

Message par sanka0579 » 22 juin 2023, 11:34

Hello,

Je te remercie pour les infos.

Je me demandais s'il ne fallait pas supprimer le container ul et remplacer les li par des div ou des span...?

Merci d'avance

Avatar du membre
webmaster
Administrateur du site
Messages : 578
Enregistré le : 28 févr. 2017, 15:19

Re: Incérmentation id div

Message par webmaster » 22 juin 2023, 12:01

Le choix des <ul> ou <div> n'a pas d'importance. C'est selon tes préférences et les besoins de mises en forme CSS.

Il y a toujours de multiples solutions à un besoin.
TJS : 25 ans et mon livre Tout JavaScript chez Dunod
https://www.toutjavascript.com/livre/index.php

sanka0579
Messages : 6
Enregistré le : 02 févr. 2023, 13:52

Re: Incérmentation id div

Message par sanka0579 » 22 juin 2023, 15:17

Ok, je comprends bien le truc.

Si tu as une idée c'est volontiers ;)

Je bloque là dessus depuis quelques temps.... :x

Répondre