Update price automatically when quantity changed on product page Magento

前端 未结 4 2097
眼角桃花
眼角桃花 2020-12-20 05:21

I am looking to have the product price automatically updated based on the quantity the customer has chosen.

Currently when you choose a custom option in magento the

4条回答
  •  悲哀的现实
    2020-12-20 05:58

    Using jquery you can do this

    $('#qty').keyup(function(){
        if($(this).val() != '' && isNumber($(this).val()) && $(this).val() > 0)
        {
           var price = $('#real_price').val() * 1;
           var qty = $(this).val() * 1;
           var total = price * qty;
           $('#price').html(total);
        }
        else
        {
           $('#price').html('500');    
        }
    });
    
    function isNumber(n) {
        return !isNaN(parseFloat(n)) && isFinite(n);
    }
    

    FIDDLE

提交回复
热议问题