This chapter introduces Drupal and Drupal Commerce while explaining the goals of the system:
Introduction to the Drupal Commerce project and its origins
The framework concept of Drupal Commerce and how this allows you to build any type of e-commerce experience on top of Drupal
Examples of the types of stores that can be created using Drupal Commerce
Drupal Commerce is a suite of modules written for Drupal 7 that enable you to create flexible, full-featured e-commerce sites. It is best described as an e-commerce framework as opposed to an out of the box shopping cart system. At the time of writing, Drupal 8 had not been released, but there is a roadmap available for the release of Commerce for Drupal 8 (http://www.drupalcommerce.org/roadmap).
Like Drupal itself, the Commerce framework components provided can be combined and extended to create any kind of e-commerce site, so you are not restrained by the default capabilities of the system.
The project is headed by Ryan Szrama of Commerce Guys; a French/American company dedicated to developing and supporting the Drupal Commerce platform. Drupal Commerce 1.0 was officially launched at DrupalCon London in 2011.
Unlike some other open source platforms, there are no premium or paid versions of Drupal Commerce. What you download from http://www.drupal.org/project/commerce is everything you need to get started.
The core Drupal Commerce download consists of the following modules:
Commerce (core module)
Cart
Checkout
Customer
Line item
Order
Payment
Price
Product
Product pricing
Product reference
Tax
The system was designed using a small core philosophy: the core modules only contain the components considered essential for every e-commerce site. For example, the shipping functionality is not included in core since it isn't necessary that every system has physical goods to ship. The rationale behind the system is to make no assumptions about the business logic of the system being built—rather it provides an extensible framework for development.
There are many modules available on Drupal.org
that extend Drupal Commerce for different use cases. We will discuss some of them in this book.
Drupal Commerce exceeded 230,000 downloads in July 2013 and is used to power some high-profile and high-volume websites.
Due to its nature as a flexible framework, Drupal Commerce is well suited to create many types of e-commerce experiences, from simple to complex.
Some examples include:
Physical products
Gifts
Books and CDs
Digital downloads
Software
Music
Subscriptions
Magazines
Events and tickets
Theatres
Conferences
Paid content access
Paywall access to content
Bespoke products
Customizable products
Greetings cards
You could also use the system to design a backend order processing system for a single-page promotional site. With a good understanding of the system, the possibilities are limitless.
Before starting out with your Drupal Commerce build, it's important to understand the key terminology used to describe the different components of the system.
Drupal 7 introduced the concept of an Entity as a way to represent a discrete piece of content. In Drupal Core, a User and a Node are entities and any entity can be extended using Fields. A Field is used to represent an aspect of content such as the title, username, or description. Drupal Commerce defines a number of new Entity types that are used as the building blocks of the system.
A product represents an item for sale on your website. It can be a physical product such as a book, or a virtual product, such as a digital download or event. You can add fields to your product to represent different elements—for example color, size or, in the case of an event, a date.
You can also define multiple types of products each with different fields to best categorize the products within your store.
In Drupal Commerce, the order entity is used to represent a customer order in any state. The moment the customer adds something to their shopping cart, a new order is created. As with products, an order can be extended with different fields to hold custom information about an order.
You can define multiple order types if your business requires a distinction between them—for example, a stock order and a subscription order.
An order is made up of one or more Line items. A line item associates a product with an order.
By default, a line item will only contain a product reference (that is, a pointer to an actual product), and quantity. Line items can be extended with additional fields allowing you to collect more specific information. You could extend this, for example, to create a personalized gift message for an order line.
You can define multiple line item types, for example, for customizable and non-customizable products.
A customer profile is used to store the personal details of your customer. An order will generally be associated with one or more Customer profiles—typically one for the invoice address and one for the shipping address.
You can extend the customer profile with additional fields if you want to collect more information from the customer. Typical uses for this might include a telephone number, special delivery instructions, and so on.
You can define different Customer profile types allowing you to collect different information for billing and shipping, for example.
If you have integrated your store with a payment gateway, the gateway module will create one or more payment transactions and associate them with your order. The contents of these vary depending on the payment gateway implementation, but typically will include the payment details and response from the card payment provider to the request for payment.
We will discuss how to use these concepts in a lot more detail in Chapter 3, Planning Your Store.
Drupal Commerce makes use of several other key Drupal contributed modules. Some of them are listed and explained in the coming sections as follows:
The Views module (http://drupal.org/project/views) is used extensively throughout Drupal Commerce for almost all the administration screens and shopping cart / checkout. The fact that almost everything in Drupal Commerce is powered by Views makes it very easy to modify the shopping experience for both the customer and store owner without the need for coding.
The Rules module (http://drupal.org/project/rules) is used in many contexts throughout Drupal Commerce including for the calculation of prices and taxes. Rules is a very flexible and extensible system and provides many options for implementing the rules of your business.
The Entity module (http://drupal.org/project/entity) allows much greater access to the entity data that makes up the Commerce system. This will be of great benefit if you start to develop more comprehensive sites using Rules and particularly if you plan to write your own Drupal Commerce modules.
Instead of defining its own Address field standard, Drupal Commerce utilizes the Address Field module (http://drupal.org/project/addressfield), which uses international standard address formats (xNAL) to ensure that all countries' address standards are supported.
The Chaos Tools (Ctools) module (http://drupal.org/project/ctools) is a utility module that allows Drupal Commerce to implement a common pluggable architecture.
The Token module (http://drupal.org/project/token) provides text placeholders that represent (and are expanded into) entity properties or fields depending on the context of where the token is used. For example, when visiting a user's profile page, the token [user]
, would represent the user's unique ID (uid) and within the context of an actual item of content such as a page,[author]
might expand to the author of the post, that is also the uid
property of the item of content.
The Pathauto module (http://drupal.org/project/pathauto) automatically generates URL/path aliases for various kinds of content (nodes, taxonomy terms, and users) without requiring the user to manually specify the path alias.
One of the most exciting aspects of working with Drupal is the fact that you can extend and customize the system to your own requirements. You can either create your own custom modules or there are hundreds of free add-on modules on the drupal.org website. So if you want to have a shipping calculation that works with your product set, or you need to get your data from a legacy database in your company, you are not limited by the initial capabilities of the software. As it is open source, you are not locked into using a proprietary vendor to make changes—you can do it yourself!
You can also find a more curated list of Drupal Commerce specific modules at drupalcommerce.org.