Shipping
There are a number of methods for specifying shipping. For starters, there are 3 variables you can set for calculating shipping: shippingFlatRate, shippingQuantityRate, and shippingTotalRate. You can also set a shippingCustom function. These 4 methods will be added up to create the total shipping cost
To set a basic flat rate shipping, you can use shippingFlatRate.
simpleCart({ shippingFlatRate: 10 });
Remember, you can set this variable at any time. (It may be useful to change it when a user sets their shipping state or country)
For a shipping rate based on the total quantity of the cart (i.e. shipping quantity rate of $3 = $21 for 7 items), use shippingQuantityRate:
simpleCart({ shippingQuantityRate: 3 });
If you want a shipping rate that is a percentage of the total cost of the cart, use shippingTotalRate:
simpleCart({ shippingTotalRate: 0.1 });
You can also add a custom function that returns a shipping cost based on arbitrary criteria. Let’s say you wanted to have the cost of shipping be $10, unless there are more than 20 items in the cart:
simpleCart({ shippingCustom: function(){ if( simpleCart.quantity() > 20 ){ return 0; } else { return 10; } } });
You can also set this custom shipping function using a shortcut in the .shipping() function:
simpleCart.shipping(function(){ if( simpleCart.quantity() > 20 ){ return 0; } else { return 10; } });
If you want to calculate shipping based on the individual items, you can modify the simpleCart.Item object to have items calculate their own shipping. Let’s say you wanted to have the shipping for each item be 2 if the item’s size is “small”, and 5 if the size is anything else:
simpleCart.Item._.shipping = function(){ if( this.get( 'size' ) == "small" ){ return this.quantity()*2; } else { return this.quantity()*5; } };
Of course, you could achieve the same effect by creating a custom shipping method for simpleCart that iterates through all the items:
simpleCart.shipping(function(){ var total = 0; simpleCart.each( function( item ){ if( item.get('size') == 'small' )[ total+= item.quantity()*2; } else { total+= item.quantity()*5; } }); return total; });
If you want to see what the total shipping is at any time, you can call the .shipping() method and the total from all of the aforementioned methods will be returned:
simpleCart.shipping(); // returns current shipping cost
Aug 28, 2012
WHY IS THERE SO MUCH SEO LINK SPAMMING LIKE ON EVERY PAGE :(
Sep 09, 2012
I was trying to use ShippingCustom so that if over over $10 then its free else $2, cant get it to work, can some0ne help me? email me: .(JavaScript must be enabled to view this email address)
or skype:vitek-uk
Thanks
Sep 29, 2012
Hi, thank u very much for the excellent javascript. However i need to ask for favor: is it possible to set up the shipping calculation based on expedition’s rate? It will be specific for each country’s buyer.
Can you help.
Thank u so much!
Oct 05, 2012
I am using the SimpleCart shopping cart and it is using cart upload method with the combined shipping for entire order being assigned to “handling_cart” variable on upload to PayPal.
This seems to be correct and what the “handling_cart” variable has been designed for. It displays the combined shipping/handling as “Shipping and handling:” on the initial order page.
On the confirmation email it uses “Postage and packaging:” as the description for combined amount.
Postage and packaging 5.00 GBP
However when you go into PayPal account page for the transaction it breaks it down as :
Postage: £0.00 GBP
Packing: £5.00 GBP
Can someone shed light on this inconsistency?
Answers to thomas crabb -AT- excite .co.uk
(remove spaces!)
As far as I can see SimpleCart is doing everything right according to PayPal specifications, so issue must be with PayPal.
Thanks,
Oct 29, 2012
I can’t open the download! I’ve tried with several different programs, help! :(