I’m trying to display a price of a product in Woocommerce, on a custom page.
There is a short code for that, but it gives product price and also adds an “Add to cart button”, I don’t want the button, i just want to get the price of a specific product by ID.
Is this possible?
Thanks.
CODE:
<table class="unlockTableBorder">
<tbody>
<tr>
<td>
<h2>פת××ת ××ש××¨× Alcatel ××× ×¢××××</h2>
<h4>×× × ×§×¨×× ××××× × ×ת ×ª× ×× ×ש×ר×ת ××××× ××¤× × ×××× ×ª ש×ר×ת ××:</h4>
<ul>
<li>ש×ר×ת ×× ×ª××× ×פת××ת ××ש×ר×× ×¡×××ר××× ×ס×× Alcatel ××ר×"×, ×§× ×× ××קס×ק×.</li>
<li>××ש××¨× CDMA ×ספק××ת ש×ר×ת CDMA ×× × ×ª×××× ×××× ×©×ר×ת ××, ×× × ×× ×ª×©×ª××©× ×ש×ר×ת ×× ×ש××× ××ש×ר×× ××× - ××××× ×תש××©× ×ש×ר×ת ×× ×××ש××¨× CDMA, ××ª× ×ª×§××× ×§×× ×©×× ×ª×××× ××שת×ש ××, ××× ×ª×××× ×ק×× ×××ר ×ספ×! - ×× × <a title="פת××ת ××ש××¨× CDMA ××× ×רשת×ת" href="http://www.unlocker.co.il/sim-unlock-cdma-mobile-device/">ר×× ×¤×ª××ת ××ש××¨× CDMA ××× ×רשת×ת ××שר××.</a></li>
</ul>
<h5><strong>××× ×ספק×: 1-24 שע×ת</strong></h5>
<form id="unlock1" class="cart" enctype="multipart/form-data" method="post" name="unlock"><input class="the_imei" style="width: 80%; border-radius: 15px;" name="the_imei" type="text" value="" placeholder="×ספר ס××××¨× IMEI ×©× ×××ש×ר (×××× #06#*)" /> <input class="add-to-cart" name="add-to-cart" type="hidden" value="76" /> <button class="unlockButton" type="submit" value="submit">×¤×ª× ××× ×רשת×ת ××שר×× </button></form>*×××××¦× ×¢× ×פת×ר, ××ª× ×ס××××× ×<a title="×ª× ×× ×ש×ר×ת" href="http://www.unlocker.co.il/terms-and-conditions/">×ª× ×× ×ש×ר×ת</a>.</td>
</tr>
</tbody>
</table>
<script src="http://www.unlocker.co.il/checkimei1.js" type="text/javascript"></script>
If you have the product’s ID you can use that to create a product object:
Then from the object you can run any of WooCommerce’s product methods.
Update
Please review the Codex article on how to write your own shortcode.
Integrating the WooCommerce product data might look something like this:
Your shortcode would then look like
[woocommerce_price id="99"]
In woocommerce,
Get regular price :
Get sale price:
Other answers work, but
To get the full/default price:
$product->get_price_html();