How to Create a Drupal Commerce Site with Drupal 8

Introduction: Drupal Commerce, Magento, or UberCart?

For Drupal 8 website publishers, there are three main ways to create a professional ecommerce solution on the platform: Drupal Commerce, UberCart, & Magento Commerce.

This Tutorial will provide an installation guide for Drupal Commerce including what is required to install the modules to run on a LAMP web server & set up the SSL/TLS certificate.

Note: Decisions as to which ecommerce platform is recommended for Drupal 8 website publishers largely depends on the IT resources and business requirements of the company or other organization that operates the website. This Tutorial is a guide to Drupal Commerce.

Let’s get started.

Step One: Install & Enable the Drupal Commerce modules.

Prerequisites: Install the Rules, Entity, Typed Data, Ludwig, & Address modules.

How to Create a Drupal Commerce Site with Drupal 8

Additionally, to run the Address module:

  • Download the commerceguys addressing library and place it in modules/address/lib/commerceguys-addressing/v1.0.0
  • Download the commerceguys intl library and place it in modules/commerce/lib/commerceguys-intl/v1.0.1

Hint: You can create the /lib/ folders in each module, then unpack the zip file & change the folder names to match the URL. Then run the test again to verify the installation using Ludwig.

Address Packages URL: /admin/reports/packages

Other Modules Required:

Install the Inline Entity Form, Entity Reference Revisions, State Machine, & Profile modules to complete the Drupal Commerce prerequisites.

Drupal Commerce - List of Modules Required:

How to Create a Drupal Commerce Site with Drupal 8

Drupal Commerce has the following module components that should be enabled:

  • Commerce: Defines common functionality for all Commerce modules.
  • Commerce Cart: Implements the shopping cart system and add to cart features.
  • Commerce Checkout: Provides configurable checkout flows.
  • Commerce Log: Provides activity logs for Commerce entities.
  • Commerce Order: Defines the Order entity and associated features.
  • Commerce Payment: Provides payment functionality.
  • Commerce Price: Defines the Currency entity.
  • Commerce Product: Defines the Product entity and associated features.
  • Commerce Promotion: Provides a UI for managing promotions.
  • Commerce Store: Defines the Store entity and associated features.
  • Commerce Tax: Provides tax functionality.

When installed together, these modules provide the foundation for building complex ecommerce solutions with Drupal 8 using Product Listings & integrating with popular payment gateways. There is also a Shopping Cart for storing orders for users while browsing, with coupons, sales, credit card/PayPal processing, traffic analytics, etc. included in the core Drupal Commerce features. Drupal Commerce is officially sponsored by the Commerce Guys.

Step Two: Drupal Commerce - Configuration Settings.

Pre-Requisites: Enable the trusted_host_patterns setting in the settings.php file.

Hint: Find out more about this issue at: /admin/reports/status

In order to fix this issue, enter the following code into your Drupal 8 settings.php file:

 $settings['trusted_host_patterns'] = array(    '^example.com$',    '^.+.example.com$',  );

Note: Change the domain values to reflect your site’s root URL address.

Next: Navigate to the Drupal Commerce administration section at: /admin/commerce

In his section, you can begin to use the tools for creating products, managing orders, setting up payment gateways, & accessing analytics.

How to Create a Drupal Commerce Site with Drupal 8

Note: From the administration section, you can access and configure the settings for products, orders, stores, payment gateways, & currencies.

How to Create a Drupal Commerce Site with Drupal 8

Hint: Adjust these settings according to your business requirements and then get started building new product pages and taking live orders.

Step Three: Products, Orders, & Workflow Management.

Use the Product Types settings in Drupal Commerce to manage fields on product nodes & the Order Types settings to manage the fields on shopping cart orders. These can include product dimensions like sizes, quantities, colors, versions, etc. Then use the Drupal 8 /node/add form to build new product pages using Drupal Commerce for order processing.

Add a Store:

How to Create a Drupal Commerce Site with Drupal 8

Settings: Add the Name & Address for your store as it will appear on invoices & save.

Note: A Store is a prerequisite in Drupal Commerce for creating Products & Orders.

Add a Product:

Navigate to /product/add/default to begin the process of adding new products to a catalog.

How to Create a Drupal Commerce Site with Drupal 8

Note: Add Taxonomy terms & Fields in the Product Settings page to filter content in to catalog categories. Then use Views & Panels to build dynamic content from Product pages into displays. Use keyword-driven URLs & Page Titles to bring in organic search traffic.

Step Four: Administration, Security, & Encryption Settings.

Drupal Commerce has over 73 Payment Gateways available for integration with the Shopping Cart. Most businesses will find one of these suitable to their website ecommerce requirements. For this Tutorial, we will only be installing the Commerce PayPal gateway.

  • Download & enable the module as usual, & then add it under: /admin/commerce/config/payment-gateways/add

How to Create a Drupal Commerce Site with Drupal 8

Note: Other popular credit card processors & payment gateways available for Drupal Commerce are: AuthorizeNet, AliPay, CCAvenue, Amazon Pay, WeChat, Stripe, Square, etc.

Try Another Option: Acquia & Magento Commerce.

With Magento Commerce, Drupal 8 developers basically have the choice of installing Magento and building a bridge between the Drupal CMS database for users using connectors & conductors, or using a pre-built integration solution from Acquia Commerce.

How to Create a Drupal Commerce Site with Drupal 8

Acquia Solutions: The upgrade of Magento Commerce integration tools for Drupal 8 is incomplete. This makes the Acquia Commerce PaaS product more interest to Drupal site owners migrating to managed cloud solutions.

Note: The Magento Commerce integration with Drupal 8 will require a professional PHP development team to develop independently or an Acquia Cloud PaaS hosting option.

Ecommerce: Which Solution is Best for Drupal 8?


Background: Small businesses & independent web publishers will be choosing between Drupal Commerce & UberCart while Enterprise companies using Drupal 8 will seek to leverage Magento for open source cost-efficiency at scale.

Acquia Commerce has a cloud service offering Drupal-Magento integration as PaaS product which is industry-unique. DIY-techs will need to make a primary choice between UberCart & Drupal Commerce, then build around it for years.

Similarities:

  • Both Drupal Commerce & UberCart allow for the creation of products with a shopping cart & credit card payment gateways + PayPal, Bitcoin, etc.
  • Both can be used to build ecommerce solutions using Views in Drupal 8.
  • Both are peer-reviewed for web/data security in production.

Recommendation: Overall, we recommend UberCart (4.5 out of 5 rating) over Drupal Commerce (4.0 out of 5 rating) due to Platform Stability in operations. The UberCart user community has a wide range of resources for solving common problems.

Note: Drupal 8 + Magento Commerce is a large-scale enterprise solution available through the Acquia Commerce cloud. The company has various plans available with customer service.

Conclusion: Solutions for SMEs, B2B, & Enterprise Scale.

Summary: This Tutorial shows how to get started with a Drupal Commerce website, building products, stores, & catalogs online with PayPal as the order processor. Use Views & Panels to list Drupal Commerce products in dynamic displays with sales & promotions.

Recommendation: Consider UberCart or Magento Commerce as alternatives.

Check out these top 3 Drupal hosting services:

Was this article helpful?