Need help in fetching woocommerce product price in javascript

Viewed 18

I wanted to know is there any way I can fetch the Woocommerce product price in the javascript.

I've entered the below code in the header of every product page in woocommerce:

<script>
const key = "key";
const amount = "Price";

window.onload = function() {
 const widgetConfig = {
    "key": key,
    "amount": amount,
 };
 const rzpAffordabilitySuite = new RazorpayAffordabilitySuite(widgetConfig);
 rzpAffordabilitySuite.render();
}
</script> 

in place of the "Price", I have to enter the product price of the opened product page. I'm not able to figure out on how can I achieve this. I just wanted to know how can I make this possible.

Thanks

0 Answers
Related