Mar 04, 2016
The Shopify forums and chat channels are chock-a-block full of merchants that subscribe to the theory that shipping is easy. Some common complaints include:
- Why can’t I have free shipping for a single product?
- Why can’t I ship free to a small list of local zip codes?
- What if I have one thing in a weird tube and everything else in a box?
- Why can’t I use dimensional weights?
All legitimate questions but also I think they all come from a well-meaning but uneducated viewpoint with respect to transportation logistics. I had brief, tumultuous but excellent education in that business before dotcom implosion numero uno, and that industry kept me afloat for at least a few years after that first dotcom implosion. Transportation Logistics, or just Logistics if you will is a mature industry, with software and systems well ahead of anything from Shopify or other ecommerce platforms in terms of reach, stability and sheer money being hustled through them. FedEx or UPS anyone?
Plugging into Shopify
Any merchant can do what they wish with shipping, a super nice touch from Shopify a lot of merchants do not realize. When a merchant complains and throws out a boomerang about Shopify not doing something right or good enough, the boomerang that comes back should knock the sensible answer of plugin whatever your heart desires mister into the mix.
Shopify will hand off to any reachable endpoint on the Internet (an URL) a payload to base shipping calculations on. The shipment origin which is where some truck will leave from with the goods, a destination that represents where the goods are going, and a list of the items in the manifest itself. The payload includes some juicy details like how many widgets of type X are to be shipped, how much each widget weighs in grams, the price, the product’s Shopify ID and its variant ID.
And no, there is no information in the payload about any Discount Codes used by the customer, so good luck if you are trying to give away shipping if the customer buys more than $100 in merchandise where you gave them a discount of $25 and therefore their cart with a $100.01 product is worth only $75.01 and you’re ticked that they get that invalid Free Shipping.
What is Hard About Shipping Again?
Imagine you are a clever shipping rate calculation machine with a payload to work with. So you have some grams. Maybe 12,700 grams. What if you want to ship them in a roundish tube that is 24 inches long and with a circumference of 6 inches? Wait a second are we mixing units here? grams and inches are not the same unit family. So now Mr. Smarty Pants machine has to ensure all units are consistent. So you ensure you have all Imperial units like inches and ounces, or centimeters and grams. Make a mistake in division by 10 or multiplication by 2.2 pounds per kg and your shipping rates could be stupid.
Assuming you have all that straight now you need to quickly decide if the weight of the package is more expensive to ship than the dimensional weight of the shipment. What is that? It turns out that shipping a small heavy thing could be as expensive as a feather in a big box. So the industry uses the more expensive value of either weight with no dimensions or weight with dimensions. So if you want to present a non-stupid rate to your customers, you better have it together and know your dimensional weights. But wait, those are not exactly easy to deal with in Shopify. Some Apps purport to make it easier but for this exposition lets just use the case here of things being in your control and you are the machine.
Did we forget to mention that you better return a rate to the customer toute de suite, like right now, as waiting too long means Shopify will drop your answer like a stone and inform the customer you have no rate to provide them shipping. Not good. The backup Shopify rate could be nasty.
Back to the action, your going through the items in checkout and you have a single product ID and its variant ID and the quantity and grams to be shipped. What can you do with all that? Ask FedEx, UPS or USPS for a rate and they will certainly give you some rates to return to the customer, but very likely not the best ones possible. For the best answer you have to ask for a rate based on the box that holds the weight, along with your special customer specific shipping key they gave you. Hang on, so how do you get that boxes’ dimensions. And what if the quantity of 3 of that item implies not one, but three of those as yet unknown boxes is appropriate. Is this complex yet?
So you store dimensions in a data structure you can access given a product and variant ID. That way you can quickly lookup the needed length, width and height of the box to ship some thing. And you make a rule that either as many things fit in that box, or each thing fits in its own box. Or you calculate the volume of each thing, and the volume of the box to hold those things, and as you stuff or fill the box with things, you keep on stuffing them in till the box is full, and then you move on to another box if needed, and you keep on stuffing it, and at the end of the box stuffing exercise, you ask FedEx, DHL, UPS, et al for how much they charge to ship all these boxes from the origin of the shipment to the destination, where the customer lives. And you present the rates to the customer, and let them choose the one rate that is right for them.
Along the way, if you find a product that is free shipping, you ignore it in all these calculations, so that the customer receives the package with the free item at no cost. That is an easy one! If the destination zip code is in a small list of zip codes that have no delivery charge, so be it! Do not charge the customer for delivery! If they live in a zone considered to be a $25 surcharge, then surcharge away and add $25.
Shipping things in boxes is crazy fun. That is something I know. But if you think you can just whip up a little script and plugin to Shopify and fix all your shipping problems, you are probably right, and high on something! But you might be wrong. And you might try some el cheapo App that purports to be your saviour, and you will be faced with a terrible screen to setup that App, with a couple of thousand senseless clicks to set all your inventory up, because you chose to use that el cheapo solution and they cannot therefore customize things just for you, but for everyone, and if everyone has different needs, well then, there is a chance that there is high level of configurability that will be in your face. And you will hate that. As it will eat at your soul and suck your time like nothing else to ensure your customers get presented with $14 and not $43. But because you present them with $43 they will abandon you in a millisecond. And if you charge them $144 but the real charge was $288, you will be bankrupt in short order. Shipping is something you have to get right.
Yes I Make Shipping Apps
And it is fun. For me. But I have to think long and hard about all the time spent trying to deliver the right prices, all the time, for everything. Thanks be to Shopify for releasing a very helpful library of shipping code that gets rates from the big dogs of shipping provided you setup the questions properly. And that is everything.