dongyanzhui0524 2013-12-18 06:36
浏览 23
已采纳

Magento将html价格值转移到购物车

I was successfully able to change the value of the "price" class on this page using this jQuery script:

jQuery("#options_46_2").click(function(){
                var priceOldValue = parseInt(jQuery('.product-options-bottom .price-box .price').text().replace(/[^0-9.]/g, ""));
                if (this.checked) {
                    var selectedWeight = jQuery("#select_32 option:selected").text();
                    selectedWeight = parseFloat(selectedWeight);
                    var priceNewValue = priceOldValue + 50 * selectedWeight;
                    jQuery(".product-options-bottom .price-box .price").html("Rs" + priceNewValue + ".00");

                }
                else {
                    jQuery(".product-options-bottom .price-box .price").html("Rs" + priceOldValue + ".00");
                }

        });

Now, I want this changed value to be the actual value of the product's price when a user clicks on "Add to cart" button. How should I do it?

Also, is there any more elegant way to do this, for other products?

  • 写回答

1条回答 默认 最新

  • dqwh1218 2013-12-18 07:27
    关注

    [EDIT]

    then you can achieve this using observer create one module and add event sales_quote_add_item this event fire after product add to cart

    and in your observer you can get product price and check option is selected or not if option is selected then you can set quote price using

    $quote_item->setOriginalCustomPrice($Custom price)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上