首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Simplecart总权重

Simplecart总权重
EN

Stack Overflow用户
提问于 2012-02-02 03:40:30
回答 1查看 827关注 0票数 0

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

代码语言: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 />   

我当前的函数是:

代码语言:javascript
复制
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;  
    }  
}  
EN

回答 1

Stack Overflow用户

发布于 2012-02-02 03:53:05

根据simpleCart文档,它们允许您自定义运输成本的方式有很多种。我特别看到的一个几乎就是我认为(帖子很难读懂)你想要的:

代码语言:javascript
复制
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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9102119

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档