The fundamental concepts of e-commerce are easy enough to grasp, and these days most e-commerce sites follow normative standards and conventions. There are three basic components: the store-front, the shopping cart, and the checkout.
In this post, I’ll discuss each of these components. How these components are implemented in code depends, like many advanced topics, on what framework you’re working with, what language, and the style of development you or your team have.
The Store-front
When someone is shopping on the web, they want to browse products on a site to see what’s available. The listing of how products are displayed on your site is termed the “store-front”.
Usually, products use categorization to make it easy for users to find the sort of products they’re looking for. If you remember from way back when, we discussed the elements of navigation that an information architect should be aware of when organizing the content of a site.
In terms of information architecture…
A shoe store typically has top-level categories such as Men’s and Women’s. A shoe store might also have one or more levels of sub-categories of each top-level category. For example, the Men’s category might have sub-categories such as Boots, Sandals, Dress Shoes, Sneakers etc. It is not uncommon for a particular product to fall into more than one category. For example, a casual hiking boot may fall under both Hiking and Casual. You may also want to add the ability for visitors of your hypothetical shoe store to search products by facets, including price, color, brand, specials, etc.
Managing the store-front of an e-commerce site is a matter of organizing products, and managing inventory. How you organize the store-front, and how you categorize your products, are important concepts to work out in the information architecture phase of an e-commerce project, since the methods of navigation and categorization that you choose will affect every aspect of the site architecture.
In terms of development…
A store-front, if you were to build one yourself, would most likely have separate database tables for categories, products, and the association of products to categories. All the data about categories and products would then be read from the database. Store-fronts must also begin a “session“, which automatically assigns a session id to the user and stores it in a cookie. This is important so that the server can track each user and make sure that one user’s shopping cart is not confused with another user’s shopping cart, even if the user’s are not registered with the site.
A typical categories table might have fields for id, title, parent_category_id, and created. A products table would typically have fields for id, title, description, num_available, price, thumbnail_image_path, large_image_path, and created. An association table could have fields for id, product_id, category_id, created, thereby allowing for a many to many relationship between products and categories by thereby having a separate row for each category a particular product belongs to.
The Shopping Cart
Shopping carts are an essential part of any e-commerce site. They take the metaphor of the physical shopping basket, and transpose it into online media. At its most fundamental, a shopping cart is tool for maintaining state and remembering which products a user has selected for purchase so that they can buy them all together as a batch without having to re-enter their billing and shipping info for each one individually.
In terms of development…
As you can probably imagine, most shopping carts are simply tables in a database that have fields for user_id, product_id, and quantity (as well as the id and created fields, of course). That way, the database table simply has a row for every product in the user’s cart. To get the contents of the cart, you make a query on the table for all rows that match a given user_id.
It may be that you want to allow non-registered users to also add items to a shopping cart. In this case, you wouldn’t be able to store their user_id in a database since they do not have a user_id. There are two ways to get around this problem: either you store the items in their cart as data in a cookie (stored on their client machines) instead of in the database, or you can add a temporary shopping cart table to the database that associates items with a user’s session_id rather than their user_id. Remember that session_ids are automatically assigned by PHP’s Sessions functionality, and do not require users to register. The temporary shopping cart table might be called, “temp_cart”. It might have fields for id, session_id, product_id, quantity, and created.
Payment Processing
The checkout and payment processing parts of an e-commerce site are the most complicated. You need to securely process a transaction on a user’s credit card. This entire process should take place on a secure server where all communication between the client and server is encrypted.
To have a merchant account or not to have a merchant account?
In order to process credit cards online, you need to have what is known as a merchant account with a bank. To charge cards over the phone, in a store, or online, merchants need these special accounts with a bank. If you do not have a merchant account with a bank, you will need to use a payment processing service like PayPal or Google Checkout, which does not require you to have your own merchant account setup. PayPal uses its own merchant account to process your payment (and of course they charge an extra fee for this.) This is why PayPal is so popular with small merchants.
Assuming you have a merchant account (or are using a payment service that does), the first step in processing payment online is to send the data of what items are in a user’s shopping cart to a script that then calculates the total fee owed, as well as an taxes and surcharges. So the first step is a transfer of information from the shopping cart to the payment processing service. Once the user enters his/her credit card, billing, and shipping info in the payment processing step, you perform a transaction on their credit card by first authorizing it with the issuing credit card company.
If the credit card authorization passes, you must process the order with the credit card company by charging their card, remove the items from the user’s shopping cart, and make sure your site’s product inventory (the num_available field in the products table) is up-to-date now that you have sold off a few items. Once everything is finished, you show a confirmation screen to the user with an order receipt. Often, the site will automatically send an email to the user (assuming they entered an email address) with the order receipt in it.
One rule of thumb to follow if you are running your own store is never store sensitive information like credit card numbers in your database. Unless you have a budget to hire a good security expert, your site can be (and very well may be) hacked, and you do not want to be liable for the damages that would result from someone getting a hold on your clients’ credit card numbers.
Due to the complication of doing all these steps yourself, most online merchants opt to use a third-party payment processing service, such as Authorize.net or PayPal, that provides security and handles all the dirty work of charging a card for them. I recommend you do the same.
Conclusion
The components of an e-commerce site are really just a new combination of the techniques and technologies you are already familiar with. However, given the amount of work it takes to get all the interaction between the parts working correctly, it can be very time consuming to set up. Also, given how important it is that you do not make mistakes or errors in any of the steps, the risk associated with developing a homemade shopping cart is pretty high.
For these reasons, I recommend you use a 3rd party content management system (CMS) to do as much of this work for you as possible. A popular 3rd party library or CMS should be well-tested, secure, easy for you to integrate with your site, and easy for the user to navigate. So when you are evaluating 3rd party tools, bear each of these issues in mind. Also determine whether the software handles all of the store-front, shopping cart, and payment processing, or only some of those parts.
There are a variety of e-commerce “solutions” that handle some or all of the components of e-commerce mentioned above.
Simple e-commerce shopping cart solutions include:
Popular solutions for both the store-front and shopping cart include the following content management systems:
- LemonStand – an e-commerce CMS. This is a commercial product.
- X-Cart – an open-source, free e-commerce CMS. Handles the store-front and shopping cart; is built to integrate with the popular payment processing services, such as PayPal or Authorize.net.
- Zen Cart -an open-source, free e-commerce CMS. Handles the store-front and shopping cart; is built to integrate with the popular payment processing services, such as PayPal or Authorize.net.
- Magento – an e-commerce CMS. Handles the store-front and shopping cart; is built to integrate with the popular payment processing services, such as PayPal or Authorize.net.
Popular payment processing solutions include:
- PayPal Payment Processing – handles just the payment processing part. Does not require you to have a merchant account with a bank. Assumes you already have a store-front and shopping cart in place.
- Authorize.net Payment Processing – handles just the payment processing part. Requires you have a merchant account with a bank. Assumes you already have a store-front and shopping cart in place.
In addition to these stand-alone solutions, there are a variety of WordPress plug-ins that add store-front and shopping-cart functionality to a WordPress site. Some popular ones include:
- WordPress e-Commerce – a WordPress plugin that adds store-front, shopping cart, and integration with payment processing services
- Shopp - a WordPress plugin that adds store-front, shopping cart, and integration with payment processing services
These are just the one’s I have heard of recently. You will find that there are dozens of PHP-based e-commerce solutions available with just a simple search.