Jump to content

Get product price with jquery


Recommended Posts

1 hour ago, Massimo333 said:

Hello,

on a prestashop prduct page, how can I get product price with jquery?

???? don't you see your price? Or do you wish to extract the price of the DB?

Link to comment
Share on other sites

  • 2 weeks later...
On 5/8/2024 at 2:01 PM, Nickz said:

???? don't you see your price? Or do you wish to extract the price of the DB?

 

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

Link to comment
Share on other sites

  • 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...