This page is archived
We're keeping this page up as a courtesy to folks who may need to refer to old instructions. We don't plan to update this page.
In this series, based on the O'Reilly Using Drupal book, we walk through a case study for an online t-shirt shop. In the process you will learn all of the basic pieces of building a store with Drupal Commerce, along with being introduced to the Feeds and Rules modules.
See our guide Using Drupal Book by O'Reilly Media to access all of our tutorials related to this book. Each series covers a chapter (or appendix).
Many businesses, both large and small, would like to take better advantage of their web presence by selling their products or services directly online. Setting up ecommerce, however, can be a very daunting task. In this series you will create an online t-shirt shop, and in the process you will learn how to use the basic pieces of Drupal Commerce, including setting up a Paypal payment system, along with an introduction to the Feeds module, for importing our catalog, and the Rules module, to set up taxes. In this lesson we'll kick things off by reviewing the requirements for the Sweet Tees store, and discuss how we'll be going about implementing them.
Additional resources
Drupal Commerce is a complete package for running an online store. As such, it actually contains numerous submodules that each implement features of an online store, and can be turned on or off depending on the precise functionality required. In this section, we’ll look at each module in turn, and outline its purpose and where it fits. In this lesson we'll get an overview of the major components of Drupal Commerce, including:
- Carts, checkout, taxes, and payment
- Customers and orders
- Products and pricing
- Additional Drupal Commerce add-ons
Additional resources
Before we get to the first step in creating our store—adding products—it’s worth taking some time to discuss and understand how Drupal Commerce treats products within the system. While product management may appear unintuitive at first, the product management features in Drupal Commerce are designed to allow for maximum flexibility. In this lesson we'll explain what product types are, and take a look at both the required fields that come with them, and the custom fields you can add.
Additional resources
The first step in setting up our online t-shirt store is to turn on a formidable array of modules to enable the Drupal Commerce module, and then set up product types for the merchandise that Sweet Tees sells: T-shirts and stickers. In this lesson we'll get the right modules enabled, configure our two product types, and then create some sample products to make sure it's all working the way we expect.
Additional resources
The Feeds module provides the capability to ingest data from any number of different sources and transform it into native Drupal constructs. It’s a versatile tool that can be used for things such as large-scale data migration, automatically populating a block of recent content from external sites, or synchronizing content posted among multiple sites. In this lesson we'll learn how Feed importers are created with the three main pieces of Fetchers, Parsers, and Processors.
Additional resources
Using Drupal, 2nd edition
Using Drupal source code
Feeds project
Now that we’re familiar with the Feeds module’s data import tools, let’s turn our attention to importing t-shirt products for Sweet Tees. Sweet Tees has kindly furnished us with a comma-separated values (CSV) file containing all of their t-shirt product data for this purpose. CSV is a common data export format from databases and spreadsheet programs. A CSV file is a simple text file that encodes a data set with each record on its own line, and a separator (such as a comma or tab) between the data values. In this lesson we'll create a feed importer for CSV files, map the CSV data to our Drupal Commerce products, and then actually import the CSV product data into our store.
Additional resources
Now that all of this groovy product data is showing up fine in the administrative interface, there’s just one problem: how do we expose these products on our public website to our customers? And further, how do we avoid displaying a product catalog with 25 entries in it, when from a customer’s point of view we only sell four products (three t-shirts and a sticker)? In this lesson we'll get an overview of how Drupal Commerce handles this with the concept of product displays and product attributes.
Additional resources
In this lesson we'll put what we just learned into action by creating a content type for product displays, and a few sample products to get the hang of how things work.
Additional resources
In this lesson we'll create a nice interface for browsing our products. We will categorize our product displays using the taxonomy system to get our like items grouped together. We'll walk through the process for creating a catalog vocabulary and terms, and then configure the content type and product type to bring it all together.
Additional resources
With our products nicely categorized, and the individual items looking good, the last step is to design a top-level catalog overview page using the Views module. In this lesson we'll create a catalog view and use relationships to pull in our product data. We'll also need to aggregate multiple products into one item so we don't have a crazy list of every possibility as individual items, and we'll wrap it all up nice and tidy by grouping the products based on taxonomy.
Additional resources
It’s easy to imagine that different kinds of stores might have certain things they want to have happen when various events take place throughout the purchasing process. For example, if someone adds more than 10 of an item to his cart, a store might want to provide a 10% discount. Or if someone was anonymous and then registers or logs in, a store might want to assign his old shopping cart to his newly found account. Traditionally, this kind of custom logic would have to be done in code by a programmer. However, the Rules module exposes a user interface for clicking together custom logic in a web-based interface. This increases accessibility to non-programmers, and also allows for bits of business logic to be shared among multiple sites with the Rules module’s import and export capabilities. In this lesson we'll review the main architectural blocks of the Rules module, covering events, conditions, actions, variables, and data selectors.
Additional resources
In this lesson we'll try a practical example of some Rules module concepts for the Sweet Tees store. Drupal Commerce’s Tax module stores its tax charging in Rules. Before we can open up our store to the public, we need to ensure that all applicable sales taxes are being applied to our items. Because Sweet Tees is based in California, we will need to charge 7.25% sales tax on all products sold if the customer lives in the state of California. This means we need to set up a conditional tax rate to only apply to California.
Additional resources
Of course, it’s one thing to have a bunch of products ready for purchase, but what Sweet Tees really cares about is accepting money for those products. They want to be able to accept credit card transactions on their online store. There's more than what's on your Drupal site involved in this though. In this lesson, we'll discuss merchant accounts and payment gateways—what they are and why you need them, along with providing payment security.
Additional resources
PayPal is a popular payment processor, especially for new site owners. It allows credit card transactions as well as payments from within PayPal itself. There are predominantly two “flavors” of PayPal’s payment processing tools: Website Payments Standard (WPS) and Website Payments Pro (WPP). For our purposes, we’ll be using Website Payments Standard, since there are no setup fees, no extra security setup required, and we can get started right away. In this lesson we'll create test PayPal buyer and seller accounts, set up access to the test sandbox, and make sure it is working properly.
Additional resources
Now that we have the PayPal side of payments set up, it’s time to set up the Drupal side of things. We’ll do this with the Commerce PayPal module, which is an extension of the main Drupal Commerce package. Just as we saw with Taxes, Commerce payment methods are Rules-enabled for maximum flexibility. In this lesson we'll walk through enabling the PayPal WPS payment method and configuring our PayPal sandbox access so that we can start taking test transactions on our store.
Additional resources
Using Drupal, 2nd edition
Using Drupal source code
Commerce PayPal project
The remaining element of our site is actually implementing the e-commerce portions: an online shopping cart and the ability to process orders, as well as reporting tools to tell us how our store is doing. We will now complete our store configuration by adding a shopping cart, configuring the checkout process, and placing a test order to make sure the whole store is actually working.
Additional resources
In this series, we have covered the basics of setting up an online storefront and shopping cart using the Drupal Commerce package for Drupal. However, there are several additional modules that you will likely want to consider before taking your online store live. We'll take a brief tour of:
Additional resources
In this series, we were able to set up a complete online store for our customer, Sweet Tees, using Drupal Commerce, a powerful, flexible e-commerce framework built on Drupal. We set up a payment system through PayPal’s Website Payments Standard. We also delved into the topic of data imports with the Feeds module, and covered tweaking Drupal’s functionality at various system points with the Rules module. In this lesson we'll tour the Sweet Tees site, discussing our implementation points, and reviewing the modules and resources we used.
Additional resources
Using Drupal, 2nd edition
Using Drupal source code
Up next: Using Drupal Appendix A: Installing and Upgrading Drupal