Woocommerce: How to display product price

I created a loop that should show the image, the name/title and the price of the product. I managed successfully to show the image and the name/title, but not the price. My knowledge of PHP is not good, but I would like to understand where I am wrong. This is my current code:

foreach ($category_slugs as $category_slug){
$products = woo_site_builder_get_products_by_category($category_slug);

echo “<ul id=’$category_slug’>”;
foreach ($products as $product):
$product_image = wp_get_attachment_url(get_post_thumbnail_id($product->get_id()));
if(!$product_image) continue;
echo ‘<li class=”structural-elements” data-category=”‘.$category_slug.'” data-productid=”‘.$product->get_id().'”><span>’.get_the_title($product->get_id()).'</span><span class=”price_section”>’.get_price($product->get_id()).'</span><img src=”‘.$product_image.'”></li>’;
echo “</ul>”;

Read more here:: Woocommerce: How to display product price

Leave a Reply

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