Simplecart 总重量

发布于 2025-01-02 08:14:53 字数 1275 浏览 1 评论 0原文

此页面描述了我的购物车,它使用 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;  
    }  
}  

This page describes my shopping cart which is using the simpleCart JavaScript library, and the function alters the shipping cost of my cart. How can I implement my function to be used with my cart?

<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 />   

My current function is:

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;  
    }  
}  

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

z祗昰~ 2025-01-09 08:14:53

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

Per simpleCart Documentation, there are many ways they allow you to customize shipping costs. One in particular I saw was almost exactly what I think (post was difficult to read) you want:

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;
    }
}

This shows how you can edit how shipping is calculated. This example any many others are available per their site documentation at: http://simplecartjs.com/documentation.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文