Jump to content

Get product price with jquery


Massimo333

Recommended Posts

  • 2 weeks later...
  • 3 weeks later...

Hello @Massimo333,

To get product price with jQuery please use the below code you need to add the below script in your theme custom.js file

Path URL: themes\{{your_theme}}\assets\js\custom.js
Code: 

$(document).ready(function() {
    var stringfyproductDetails = $('#product-details.js-product-details').attr('data-product');
    var productDetails = JSON.parse(stringfyproductDetails);

    $('.product-price-jquery').text(productDetails.price)
})

and need to show on the product page need to add a div like below screenshot
Screenshot: https://prnt.sc/vevD3B2yS_-N

Path URL: themes\{{your_theme}}\templates\catalog\product.templates
Code: 

{* Custom Price Show using JQuery *}
Product Price using Jquery:
<div class="product-price-jquery"></div>
{* Custom Price Show using JQuery *}

 

After making these changes to your template files, please clear the cache to see the updates on the front end.
Preview: https://prnt.sc/7b4GxSp7uEjF

 

Link to comment
Share on other sites

On 5/21/2024 at 2:36 PM, Massimo333 said:

 

I need to extract the price from the product page by jQuery.

when editing a .php or .tlp download the file, rename it with adding a 2 or any letter you wish to use. Upload it to the same location.
That way you create a back up for the file you wish to edit. Be mindful as some ftp have downloaded empty files. It can happen. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...