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)

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

报告相同问题?