I want to make a custom product loop based on a list of products from a relationship field in Advanced Custom Fields.
So far, everything works fine except the display of the product price.
Here's my current code:
<?php $featured_posts = $products_select; if( $products_select ): ?>
<div>
<ul>
<?php foreach( $featured_posts as $post ): setup_postdata($post); ?>
<?php wc_get_template_part( 'content', 'product' ); ?>
<?php // wc_get_template( 'loop/price.php' ); ?>
<?php endforeach; ?>
</ul>
<?php wp_reset_postdata(); ?>
</div>
<?php endif; ?>
The code shows the products with image, title and ratings. But the price is missing. The price shows if I uncomment the following line:
<?php wc_get_template( 'loop/price.php' ); ?>
But that should be a part of wc_get_template_part( 'content', 'product' );
?!
I really want to use wc_get_template_part( 'content', 'product' )
. And therefore it would be great if the price would work without extra code.
Is there anything I'm missing in the custom loop?
It would seem as though the action woocommerce_template_single_price
has been unhooked somewhere else in your code.
Otherwise, you should be able to re-add it at a later priority
add_action('woocommerce_single_product_summary', 'woocommerce_template_single_price', 15);