Home Web Development Getting Started with Drupal Commerce

Getting Started with Drupal Commerce

By Richard Jones
books-svg-icon Book
eBook $25.99 $17.99
Print $43.99
Subscription $15.99 $10 p/m for three months
$10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
BUY NOW $10 p/m for first 3 months. $15.99 p/m after that. Cancel Anytime!
eBook $25.99 $17.99
Print $43.99
Subscription $15.99 $10 p/m for three months
What do you get with a Packt Subscription?
This book & 7000+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook + Subscription?
Download this book in EPUB and PDF formats, plus a monthly download credit
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with a Packt Subscription?
This book & 6500+ ebooks & video courses on 1000+ technologies
60+ curated reading lists for various learning paths
50+ new titles added every month on new and emerging tech
Early Access to eBooks as they are being written
Personalised content suggestions
Customised display settings for better reading experience
50+ new titles added every month on new and emerging tech
Playlists, Notes and Bookmarks to easily manage your learning
Mobile App with offline access
What do you get with eBook?
Download this book in EPUB and PDF formats
Access this title in our online reader
DRM FREE - Read whenever, wherever and however you want
Online reader with customised display settings for better reading experience
What do you get with video?
Download this video in MP4 format
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with video?
Stream this video
Access this title in our online reader
DRM FREE - Watch whenever, wherever and however you want
Online reader with customised display settings for better learning experience
What do you get with Audiobook?
Download a zip folder consisting of audio files (in MP3 Format) along with supplementary PDF
What do you get with Exam Trainer?
Flashcards, Mock exams, Exam Tips, Practice Questions
Access these resources with our interactive certification platform
Mobile compatible-Practice whenever, wherever, however you want
About this book
Drupal Commerce is emerging as the preferred option for open source e-commerce, and it also stands up to comparison against established proprietary systems. Getting Started with Drupal Commerce is an introductory guide to building an online store using Drupal Commerce in Drupal 7. Getting Started with Drupal Commerce takes you step-by-step through a complete e-commerce website build, from a clean installation of Drupal to a working example store. Starting with how to set up a Drupal development environment, we then discuss the planning of an e-commerce site and the typical questions you should be asking before getting started. Next, we walk through all of the essential setup required for most types of e-shop, including taxes, shipping, discounts and coupons, the checkout process, and backend order management. By the end of Getting Started with Drupal Commerce, you will be fully-equipped to plan and build your own store and you will understand the fundamental principles of Drupal Commerce that will enable you to progress to more complex store builds.
Publication date:
September 2013
Publisher
Packt
Pages
152
ISBN
9781783280230

 

Chapter 1. Introducing Key Concepts

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

 

An introduction to 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.

 

Products that can be sold


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.

 

Key terminology


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.

The Product module

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.

The Order module (commerce_order)

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.

The Line item module (commerce_line_item)

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.

The Customer profile module (commerce_profile)

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.

The Payment transaction module (commerce_payment_transaction)

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.

 

Prerequisites and dependencies


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

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

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

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.

The Address Field module

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 module

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

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

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.

 

Customizing and extending


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.

 

Summary


By the end of this chapter, the reader should have an understanding of the potential of Drupal Commerce and how it came about. They should also understand the motivation of the developers.

About the Author
  • Richard Jones

    Richard Jones is a technical director at iKOS—a European digital agency specializing in Drupal. Richard's first computer was an 8-bit BBC Master and this began his journey into computing proper. Indeed, his first introduction to working with Nick was by way of a school database project using the then legendary Acorn ViewStore package—way ahead of its time as an EPROM-based offer

    Browse publications by this author
Getting Started with Drupal Commerce
Unlock this book and the full library FREE for 7 days
Start now