请问如何让商品价格+运费?已知运费和商品价格

浏览:737 发布日期:2015/11/10 分类:求助交流
通过JS获取产品价格,现在我在表里加了个运费字段,模板上已经可以获得运费字段,我现在想在结算的时候+上运费,请问应该如何改这个JS标签。。
模板代码                        <script>
                        window.onload=function(){
                            showDetail('{$shops.id}');
                            doProduct('{$shops.id}','{$shops.name}','{$shops.old_price}','{$shops.y_price}');
                            $('#cart').click();
                        }
                        </script>

                    </div>
                </dl>
            </section>
        </section>
    </div>
<div id="cart-container" style="display: block;">
<div class="orderlist">
                <ul id="cartinfo">
                    <li class="ccbg2" id="emptyLii">{$shops.name}</li>
                </ul>
                <if condition="$buy_cnt neq 0">
                <ul id="cartinfo">
                    <li class="ccbg2" id="emptyLii">已选:<span id="totalNum">0</span> 份,共计:<span id="totalPrice">0</span> 元</li>
                    <li style="display:none"><span id="totalLirun">0</span></li>
                </ul>
                </if>
这个下面是引用JS的function doProduct (id , name , price,lirun) {
    var bgcolor = $('#'+id).children().css('background-color').colorHex().toUpperCase();
    if (bgcolor == '#FFFFFF') {
        $('#'+id).children().css('background-color','#D00A0A');

        var cartMenuN = parseFloat($('#cartN2').html())+1;
        $('#totalNum').html( cartMenuN );
        $('#cartN2').html( cartMenuN );

        var totalPrice = parseFloat($('#totalPrice').html())+ parseFloat(price);
        $('#totalPrice').html( totalPrice.toFixed(2) );
        var totalLirun = parseFloat($('#totalLirun').html())+ parseFloat(lirun);
        $('#totalLirun').html( totalLirun.toFixed(2) );

        var weshopId = 'weshop_'+id;
        var html = '<li class="ccbg2" id="'+weshopId+'"><div class="orderdish"><span name="title" style="display:none;">'+name+'</span>选择份数:<span class="price" id="v_0" style="display:none;">'+price+'</span><span style="display:none; class="price">元</span></div><div class="orderchange"><a href=javascript:addProductN("'+weshopId+'_'+price+'") class="increase"><b class="ico_increase">加一份</b></a><span class="count" id="num_1_499">1</span><a href=javascript:reduceProductN("'+weshopId+'_'+price+'") class="reduce"><b class="ico_reduce">减一份</b></a></div></li>';
    
        $('#ullist').append(html);
    }else{
        $('#'+id).children().css('background-color','');

        var cartMenuN = parseFloat($('#cartN2').html())-1;
        $('#totalNum').html( cartMenuN );
        $('#cartN2').html( cartMenuN );

        var totalPrice = parseFloat($('#totalPrice').html())- parseFloat(price);
        $('#totalPrice').html( totalPrice.toFixed(2) );
        var totalLirun = parseFloat($('#totalLirun').html())- parseFloat(lirun);
        $('#totalLirun').html( totalLirun.toFixed(2) );

        var weshopId = 'weshop_'+id;
        $('#'+weshopId).remove();
    }
}
最佳答案
评论( 相关
后面还有条评论,点击查看>>