Simplecart总重量

时间:2012-02-01 19:40:30

标签: javascript e-commerce shopping-cart

此页面描述了使用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;  
    }  
}  

1 个答案:

答案 0 :(得分:0)

根据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