简体   繁体   中英

How do I calculate shipping in Simplecart based on total quantity?

My client requires shipping rates based on quantity of items in the order.

1-10 books - $4 11-24 - $5.50 25-49 - $7 50-99- $8.50 100-199 - $11 200-299 - $16 300-399 - $23 400-499 - $30

I've been trying to tweak the JavaScript a week now. Anybody know Simplecart well enough to send me in the right direction?

You should not have to change the core files.

See http://simplecartjs.org/documentation/shipping

simpleCart.shipping(function(){
    if( simpleCart.quantity() <= 10 ){
         return 4;
    }
    else if( simpleCart.quantity() < 25 ){
         return 5.5;
    }
    else if( simpleCart.quantity() < 50 ){
         return 7.5;
    }
    else if( simpleCart.quantity() < 100 ){
         return 8.5;
    }
    else if( simpleCart.quantity() < 200 ){
         return 11;
    }
    else if( simpleCart.quantity() < 300 ){
         return 16;
    }
    else if( simpleCart.quantity() < 400 ){
         return 23;
    }
    else if( simpleCart.quantity() < 500 ){
         return 30;
    }
    else {
         return 30; // amount for > 500
    }
});
simpleCart({
  shippingCustom: function () { 
    if (simpleCart.quantity() > 50) {
      return 0;
    } else if (simpleCart.quantity() > 20) {
      return 10;
    } else {
      return 20;
    }
  }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM