Drupal Commerce 2.x
Blog

Getting Started With Drupal Commerce 2.x - Part 1

Drupal Commerce 2.x overview

E-commerce in Drupal 8 is a very interesting topic for many developers and this blog is the right place to start with E-commerce in drupal 8.

Drupal Commerce 2.x is the module for creating online stores of varying complexity. This blog provides an overview of the Commerce 2.x module for Drupal 8.

In this blog, we will be focusing on following things

Installing Drupal E-Commerce 2.x

To install Drupal Commerce, make sure that your server has a Composer dependency manager installed. In Drupal 8, Commerce requires the installation of libraries, which are now installed not manually but with the help of Composer. Make sure Composer installed globally.

You can install Drupal, as well as Commerce together with the dependent modules and libraries with this command:

“composer create-project drupalcommerce/project-base mystore --stability dev”

Everything will be installed to “mystore” folder

Installing Drupal Commerce 2.x on an existing site

We need to do the following steps for Installing Commerce 2.x in existing Drupal 8.x site.

Step 1: Add the Drupal packagist repository which allows Composer to find Commerce and the other Drupal modules. For that run the following command,

"composer config repositories.drupal composer https://packages.drupal.org/8"

Step 2: The following command will he'""lp us to download the required libraries and modules (Address, Entity, State Machine, Inline Entity Form, Profile).

“composer require "drupal/commerce 8.2.x-dev"

Step 3: Enable the all commerce related submodules like  “commerce_product commerce_checkout, commerce_cart” , Use drush or drupal console.

"drupal module:install commerce_product commerce_checkout commerce_cart"

Settings in the admin interface in new Commerce 2.x

Go to the commerce settings (admin/commerce/config).

1. Currency :

It is very easy to use the currency inside and Outside the US.

First, you need to select your store currency (admin/commerce/config/currency). By default, the currency list is empty (you will see the message “there is no currency yet”). The list of currencies needs to be imported. Select the desired ones on the currency import page (admin/commerce/config/currency/import).

 

Import Currencies

Now, at the Currency page, we see a list of currencies.

Currency Page

2. Store :

In the version for Drupal 8, you can create a store or multiple stores , which may vary by products, currencies, tax settings, shipping countries and so on. In Commerce 1.x (Drupal 7) there was no such entity as "store".

You can create your own type of stores (on the admin/commerce/config/store-types page) and add a variety of fields. On the admin/commerce/stores page, click Add new store.

At this step, we configure the store: give it a name, specify its email, country, currency, and other settings.

 

Add A Store

Now, at the Store page, we see our new store.

 

Store Page

 

In this way, in Drupal 8 we can now create multiple stores that have different settings (email, address, default currency, tax settings, etc.).

Each drupal store will have its own cart and checkout. In the second part of this article, next week we will create products.