0

I am unable to find one ajax script . Can any body tell me where is the script written for this page https://prnt.sc/szvwqu On selection of attributes , how the price gets changed ? where can i find the script for this?

0

For the price, there is a json in your page with all variants and prices. So no ajax request is needed to change the product price. If you take a look on your page source you will find something like this: enter image description here

You have to search "spConfig".

This json is created here: \Magento\ConfigurableProduct\Block\Product\View\Type\Configurable::getJsonConfig

The JS that renders this options on frontend is located in: /vendor/magento/module-swatches/view/base/web/js/swatch-renderer.js

The JS that updates the price value is located here: /vendor/magento/module-catalog/view/base/web/js/price-box.js

2
  • Thanx. i want to ask one thing . when i am doing some customisation for the price displayed here prnt.sc/t00ymw it is getting affected in related products too prnt.sc/t00ytn. How can i separate these two . i want to customise only above price – Nafsss Jun 15 '20 at 11:14
  • i dont know what page is that, but for sure there is a product list with a simple variant pre loaded. In my case, i had to load a simple variant based on some rule (color, special price etc) So i overrided this template, /vendor/magento/module-catalog/view/frontend/templates/product/list.phtml and passed a simple variant to the getProductPrice method on line 74. – Mattia Kozianowski Jun 15 '20 at 13:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.