woocommerce wrong product infos

this is a problem i’ve been working on for the whole day without finding any solution. I don’t understand :

After the standard product category loop, i have this code :

   $args = array( 'post_type' => 'product', 'posts_per_page' => 10, 'product_cat' => $category->slug );
            $loop = new WP_Query( $args );
        <div class="row">
            <?php global $rowSum;$rowSum=0; ?>
            <?php while ( $loop->have_posts() ):  $loop->the_post();  ?>
                <?php  wc_get_template_part('content', 'product-4'); ?>
            <?php endwhile; ?>

        <?php wp_reset_query(); ?>

In the content_product-4.php file I can correctly display all the product data, for example with :

var_dump($product); //perfect

but when i use :

<?php echo wc_get_template('single-product/price.php'); ?>

it gives me the price of the first product from the standard listing (the main query of the page)

What is really strange to me is that if I copy paste the content of the -product/price.php template it works :

<p class="price"><?php echo $product->get_price_html(); ?></p>

I really don’t understand what is the reason, this code used to work on a previous server. The new server uses Apache 2.4+PHP5-FPM

It seems to be something related with “global” keyword but i can’t find the solution. Thank you very much for your answers.


Read more here: woocommerce wrong product infos

Leave a Reply

Your email address will not be published. Required fields are marked *