How to display woocommerce sale price or regular price if there is no sale price

In WooCommerce, you can display the sale price or regular price of a product using the following code snippet:

<?php

global $product;
if ($product->is_on_sale()) {
  echo $product->get_sale_price();
} else {
  echo $product->get_regular_price();
}

You can add this code snippet to the template file of your theme where you want to display the price, such as content-single-product.php or woocommerce/single-product/price.php.

This code checks if the product is on sale, and if it is, it will display the sale price. If the product is not on sale, it will display the regular price.

Make sure to use the correct hooks and filters to place this code snippet in the right place.

Also, you can use the following code snippet to display the sale price with a strikethrough and the regular price instead of only one of them

<?php

global $product;
if ($product->is_on_sale()) {
  echo '<del>' . wc_price($product->get_regular_price()) . '</del>';
  echo '<ins>' . wc_price($product->get_sale_price()) . '</ins>';
} else {
  echo wc_price($product->get_regular_price());
}