【问题标题】:Simplecart Total WeightSimplecart 总重量
【发布时间】:2012-02-01 19:40:29
【问题描述】:

这个页面描述了我的购物车,它使用了simpleCart JavaScript 库,这个函数改变了我购物车的运费。如何实现我的功能以与我的购物车一起使用?

<div class="simpleCart_items"></div>
<a href="#" class="simpleCart_empty">Svuota Carrello</a>
<strong>Sub Total: <span class="simpleCart_total"></span></strong> <br />
<strong>TAX:<span class="simpleCart_taxCost"</span> </strong> <br />
<strong>Productions numbers:<span class="simpleCart_quantity"></span></strong> <br />
<strong>Total Weight:???????</span></strong> <br />
<strong>Shipping:????</strong> <br />   

我目前的功能是:

me.shipping = function() 
{  
    var q = 0;  
    q += item.weight*item.quantity;  

    if(q <= 3000){  
        return 19.00;  
    }  
    if((q <= 10000)) {  
        return 23.00;  
    }  
    if((q <= 20000)){  
        return 24.00;  
    }  
    if((q <= 30000)){  
        return 26.00;  
    }  
    if((q <= 50000)){  
        return 32.00;  
    }  
    if((q <= 75000)){  
        return 35.00;  
    }  
    if((q <= 100000)){  
        return 39.00;  
    }  
}  

【问题讨论】:

    标签: javascript e-commerce shopping-cart


    【解决方案1】:

    根据 simpleCart 文档,您可以通过多种方式自定义运费。我特别看到的一个几乎正是我认为的(帖子难以阅读)你想要的:

    CartItem.prototype.shipping=function(){
    // we are using a 'size' field to calculate the shipping,
    // so we first make sure the item has a size
        if(this.size){
            if( this.size == 'small' ){
                return this.quantity*5.00;
            } else if( this.size == 'large') {
                return this.quantity*7.50;
            } else {
                return this.quantity*10.00;
            }
        } else {
            // use a default of $2.00 per item if there is no 'size' field
            return this.quantity*2.00;
        }
    }
    

    这显示了如何编辑运费的计算方式。这个例子还有很多其他的可以在他们的站点文档中找到:http://simplecartjs.com/documentation.html

    【讨论】:

    • 坦克。重量不同的运输功能是不可能的。我的客户商务藤的重量。重量
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多