2012-02-01 49 views
0

本頁面描述了我的購物車,它使用了simpleCart JavaScript庫,該功能改變了我的購物車的運輸成本。我怎樣才能實現我的功能與我的購物車一起使用?Simplecart總重量

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

回答

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

+0

坦克。運送重量不同的功能是不可能的。我的客戶商業葡萄爲重量。重量<3000 = 19歐元;體重<10000 = 24歐元等... – Gio73 2012-02-02 09:11:13