Skip to content

Instantly share code, notes, and snippets.

@aarifhsn
Created December 25, 2015 08:57
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save aarifhsn/d0535a720d13369010ce to your computer and use it in GitHub Desktop.
Save aarifhsn/d0535a720d13369010ce to your computer and use it in GitHub Desktop.
Woocommerce get price in custom loop
<?php
global $woocommerce;
$currency = get_woocommerce_currency_symbol();
$price = get_post_meta( get_the_ID(), '_regular_price', true);
$sale = get_post_meta( get_the_ID(), '_sale_price', true);
?>
<?php if($sale) : ?>
<p class="product-price-tickr"><del><?php echo $currency; echo $price; ?></del> <?php echo $currency; echo $sale; ?></p>
<?php elseif($price) : ?>
<p class="product-price-tickr"><?php echo $currency; echo $price; ?></p>
<?php endif; ?>
@the94air
Copy link

the94air commented Apr 9, 2018

Thanks! that helped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment