Author:
Source
Using a framework that offers deep customization is essential for almost every e-commerce store. Today, we’re going to talk about one such e-commerce framework – Drupal Commerce. With Drupal Commerce, you get the flexibility of Drupal and the power of innovation. Let’s take a closer look at some of its features and architecture in this article.
The Relevance of E-commerce Today
Global Reach: With an internet connection, anyone can access e-commerce platforms worldwide.
24/7 Accessibility: Enjoy the convenience of anytime access.
Diverse Product Offerings: Unlike offline shopping, where options are limited, e-commerce opens the door to a wide variety of products.
Economic Growth: E-commerce fosters economic growth by offering a broad spectrum of products, breaking free from the constraints of limited stock seen in offline shopping.
Contactless Transactions: Embrace the ease and safety of contactless transactions in the digital shopping realm.
Choosing Drupal Commerce
Now, the next question arises: Why should we choose the Drupal Commerce platform for e-commerce?
Considering the myriad CMS platforms in the market such as Magento, WordPress, Shopify, and Drupal, selecting the right platform can indeed be challenging.
Here are some reasons for opting for Drupal as your e-commerce platform:
Open-source and extensible
Flexibility for complex business needs
Rules-based architecture
Community support and modules
Integration with third-party services
Stands out for businesses aiming to create a user-friendly and easily accessible e-commerce platform.
Key Features of Drupal Commerce
Take a look at some key features of Drupal Commerce that you might like:
Integrations – Drupal provides extensive integration possibilities with third-party services and tools. E-commerce websites can seamlessly integrate with payment gateways, shipping providers, and other essential services.
Rules-Based Architecture – Drupal Commerce, as part of Drupal, integrates with the Rules module. This allows administrators to define complex business rules and workflows, providing flexibility in managing various aspects of the e-commerce process.
Headless and Decoupled Architecture – Drupal supports headless and decoupled architectures, allowing businesses to use Drupal as a back-end while using a different front-end technology. This flexibility is beneficial for creating unique and tailored user interfaces
Additional Features:
Multiple stores – Easily create and manage multiple stores with Drupal Commerce.
Multiple currencies – Handle transactions in multiple currencies.
Flexible and Extensible
Powerful Content Management
Community Support
Theming and Responsive Design
SEO-Friendly
Multilingual Capabilities
Security
Drupal Commerce Architecture and Components
Now, let’s delve into the architecture and components of Drupal Commerce. There are different types of entities in Drupal Commerce, including,
Store: Can products be added without a store? Absolutely not! A key element in Drupal Commerce, the store, plays a crucial role in controlling billing and shipping countries available during the checkout process. Each store can even have its own currency, a boon for dealing with multiple currencies across locations.
Product Architecture: Understanding the product structure is key before diving into adding products in Drupal Commerce.
Imagine your store selling t-shirts or shirts. These products come in various sizes, colors, types, fabrics, etc.
To handle this complexity, Drupal Commerce introduces Product Attributes. For example:
Product Type: t-shirt
Size: Product Attribute
Color: Product Attribute
In Drupal Commerce:
There’s a single product entity.
This product entity comprises 7 different product variations.
Size Product Attribute has 3 values: Small, Medium, and Large.
Color Product Attribute has 4 values: Green, Orange, Red, and Blue.
Order Entities: Order entities contain information about the product, its variation, and customer details.
Order Items: These represent purchased items within the order.
Order Types: Each order type has its own settings for the cart and checkout pages.
We’ll discuss more practical implementations of this later.
Implementing Drupal Commerce
Prerequisites
Make sure you have a web server that satisfies Drupal’s requirements
The preferred memory limit is 256MB or more.
Latest version of Composer to manage dependencies.
DDEV or lando for local development.
Drupal Installation
composer require “drupal/commerce”Enable Commerce
drush en commerce_product commerce_checkout commerce_cartGetting Started
Create a Store
From the toolbar navigate to Commerce > Configuration > Store > Stores and click on the Add Store button. Once you add the store, you will be able to add and display products easily.
Configure different product entities
To add a new Product inside a Store, let’s first create a Product Type by navigating to Commerce > Configuration > Product types from the toolbar menu or visit /admin/commerce/config/product-types
Click on Add Product type button
When you select Product variation type as “Create new” then you don’t need to add Product variation additionally.
Now, let’s create Product Attributes for the same Product Type by navigating to Commerce > Configuration > Product Attributes or simply visit /admin/commerce/product-attributes and click on the “Add product Attribute” button.
While adding a Product Attribute, you will notice that the Product variation types (created in step 2) are present and you can map your attributes to your variations. As a result, these attributes will be visible when you add variations to any product.
Here in the above example, we have created a Product Attribute as Color, in which we have listed different colors.
Similarly you can create different Product attributes like Size, Type, etc.
Now that you have created a Store, Product Type, Product Variations, and Product Attributes, it’s time to create a new Product.
Add Products
1. To add a Product navigate to Commerce > Products and click on the “Add Product” button.
2. Enter your Product Details and click on “Save and add variations”.
3. Add your different product variations.
Displaying Products
Product display pages
First, you will need to customize the product pages from the “Manage Display” tab option. For multi-product displays, simply create a view page to display multiple products.
Add to cart form
Next, include the Add to Cart form on product pages or the other pages from where the user can add the products to the cart.
To include the “Add to cart” form, navigate to Commerce > Configuration > Orders > Order Item Types and then navigate to “Manage Form Display” of the particular order item (here we used Default)
Product images
To add Product Images, you need to add a field inside the Product Variation Type entity so that different images can be uploaded for every different Product variations.
Further, you can learn how to use the Drupal Core Image module to create a custom image style for products.
To create a custom view mode for product variations, you can use the Image delta formatter module.
Add Payment Gateway
By default, Drupal Commerce provides a COD (Cash On Delivery) payment gateway, but you can configure different payment gateways as well. To learn more about how to add a payment gateway click here.
Orders
You can manage your orders from the Orders page by navigating to Commerce > Orders.
Final Thoughts
Choosing the right framework for your unique e-commerce business is absolutely crucial. A robust and customizable framework like Drupal Commerce is not just an option; it’s a strategic necessity. Combining the flexibility of Drupal with a flair for innovation, Drupal Commerce stands as a powerful solution for varied e-commerce needs. If you’re looking to build or enhance your e-commerce solution, we have the Drupal development expertise and experience to bring your vision to life. Let’s make it happen!