0

This question is an exact duplicate of:

Hi i would like to change my product price dynamically while change the custom option text field value.

I have written the code as shown below

app/design/frontend/Smartwave/porto/Magento_Catalog/templates/product/view/options/wrapper.phtml

<script>
require(["jquery","Magento_Catalog/js/price-utils"],
function(jQuery,priceUtils) {
var finalPrice=500;
var formatedPrice = priceUtils.formatPrice(finalPrice);
jQuery('span.price-final_price > span.price-wrapper >span.price').text(formatedPrice); 
});  
</script>

marked as duplicate by Community Feb 28 '17 at 6:32

This question was marked as an exact duplicate of an existing question.

0

I found a solution The below script has been written in the template file (wrapper.phtml)

app/design/frontend/Smartwave/porto/Magento_Catalog/templates/product/view/options/wrapper.phtml


    <script type="text/javascript">
    require(['jquery','Magento_Catalog/js/price-utils','jquery/ui'], function ($,priceUtils) 
    {
     $(document).ready(function(){

        $('.CabWidth').on('change', function(){ 

        var finalPrice='200.55';
        formatedPrice = priceUtils.formatPrice(parseFloat(finalPrice));
        jQuery('span.price-final_price > span.price-wrapper > span.price').text(formatedPrice);
        finalPrice=(pricePerText*textObjects)+(pricePerImage*imageObjects);
        formatedPrice = priceUtils.formatPrice(parseFloat(finalPrice));
        jQuery('span.price-final_price > span.price-wrapper > span.price').text(formatedPrice);    

        });
    });

    });
    </script>

Note: Magento2rootFolder/vendor/magento/module-catalog/view/base/web/js/price-utils.js copied and pasted to below path

Magento2rootFolder/app/design/frontend/Smartwave/porto/Magento_Catalog/web/js/price-utils.js

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