Ask HN: What is a shopping cart and why wouldn't I just write my own?

6 points by karlrossmann ↗ HN
Hi HN-

I'm having trouble understanding a very basic concept. I build an online store, and since I'm a programmer, I let the user collect their items in a table associated with their session id. Then, I compute the order total. My server goes to the payment gateway server and charges the credit card. Then I ship stuff. What is the purpose of a shopping cart and why would I pay for a 3rd party one? They all appear to require some kind of programming, but if I already know how to program, why wouldn't I just build my own?

Note: I'm not being a smart-ass, I really don't understand what I'm missing, but I'm obviously missing something. Can someone explain what a shopping cart is to an e-commerce newbie?

Thanks for any help, Karl

16 comments

[ 3.0 ms ] story [ 37.9 ms ] thread
You can definitely write your own shopping cart if you want, its just that its a problem that so many businesses have solved before so you'd likely just be wasting time reinventing the wheel when you could be building up other aspects of your business, finding clients, marketing, etc.
See, this is what I don't understand. Building a shopping cart is like 15 minutes of work if I'm already building my own e-commerce site, isn't it? Are 3rd party shopping carts for non-programmers? I mean, as far as I can tell, it's literally just a session-associated table of items. What else is a shopping cart besides that? Why would I spend 2 days reading the "Zen cart" manual and API when I can finish my home brewed shopping cart in 15 minutes? Again, I'm not being a smart-ass, I really don't see what I'm missing. (thanks for your reply)
Robert Morris wrote Viaweb's shopping cart. He is a smart programmer, and he found it nontrivial. Years later he was still encountering bugs from weird combinations of user actions.
Dell finds it nontrivial as well. I just used their shopping cart. At one point it wiped out the entire contents of my cart when I added an item from a different section.
You are right Karl but the shopping cart which you'll end up creating will be something which just serves the bare bone needs.

Some of the other features of a shopping cart

1. Integration with a checkout system (Single page Vs Multi Page) - this is itself a demon in itself.

2. Bells and Whistles on the cart itself like tax & shipping cost estimator

I guess when you say you can create a shopping cart in 15 mins you are not keeping in mind any checkout flow integration or estimators or much control with items in the cart e.g. changing sku options like color etc.

There are some open source systems like Magento which can be looked at too.

Well, to expand on that, a lot of people don't just use the shopping cart, but all of the combined stuff like payment processing, the CMS for adding in products, user accounts, built-in APIs and many other features.

I was involved with an ecommerce startup that built all of this from scratch to control everything legally and then sell it, and quite honestly, it is an absolutely incredible amount of work.

Usually, it is easier to find software that's already been written to meet your needs unless you're trying to create a unique value proposition in some way.

If you're building a standard e-commerce site, it might make sense to use some software package that's prebuilt with what you need.

Either way, if you think you can do it in 15 minutes and want to build it, have fun with it and do it yourself.

ah, ok, this make sense. So, the ecommerce programmer would write all of the catalog stuff, then hand it over to a 3rd party shopping cart for payment, coupons, taxes and shipping, etc.? is that that non-trivial part?
- web based admin interface - Creating a browseable catalog - integration with various payment options - promotions, coupons, sales - shipping related features - CMS/website builder features

There are a lot of features an simple online shop might want to use. Cart is used as a general term

If it's only 15 minutes of work, why would you bother asking the question at all?
Because I'm obviously missing something. What else is a shopping cart besides a session associated table?
Some things your shopping cart might be missing which are non trivial.

  - Coupons or PROMOS ( X% off, $Y off, stackable)
  - Persisting a shopping cart between visits if an user doesn't checkout.
  - Saving items from a shopping cart to wishing list and vice-versa
  - Integration with multiple payment gateways but exposing a single interface
I think you're misunderstanding what an off the shelf shopping cart is. It's not just a way of storing the items a user has chosen along with their quantities, like you say, all that requires is a session array.

It's product management and categorising, product options, coupons and discounts, multiple tax rates, bulk buy discounts, user registration, payment gateway integration, promotions, image galleries, I could go on.

Basically when you buy an off the shelf system like zen cart, you're getting an entire e-commerce site that you just configure and style. And even if it's not a full site, but a PHP library to interface with your own site, it's a lot more than just the action of storing product id's and quantities in a session.

wow, thanks Matt. This is the answer i have been waiting for. this is my misunderstanding. i get it now, it's not that a basic shopping cart isn't trivial, it's that it quickly expands to a full time job. thanks for enumerating specifics.
I would also add that an off the shelf cart system will come with a fully fledge back end. This is nice because you can make use of reusable product options, discounting, automated email receipts, etc. But it's even nicer because you can get admin reporting like month to month sales figures, daily totals, most popular product rankings, and running discount totals. Sure you can track this in Excel but the point is that you don't have to. The ability to update, adjust and refund orders from an interface integrated with the store is nice, too.

Absolutely you can roll your own, but unless you have a really defined and limited product range it's just likely your needs will scale more quickly than your code, is all.

Because you're going to get it wrong. No offence intended, I would too, but if you haven't been sleeping, eating, breathing security for a while, you're going to make a mistake, and it'll cost people.

And all the other points about it needing more functionality than you'd expect.