This guide covers installing Drupal Commerce, an e-commerce implementation designed specifically for Drupal. At the end of this guide you will have a:
- Drupal Commerce site
- GitHub repository
- Circle CI configuration for testing
Make sure you have updated to Drupal 9
Drupal 8 reached end-of-life status in November 2021, and is no longer supported by Drupal. Read the official announcement on Drupal.org.
Follow the Before You Begin section of the Build Tools guide to install Terminus and the Terminus Build Tools plugin on your local computer, and create machine tokens for GitHub and CircleCI. Export the tokens to your current terminal session, as described below.
Export the variables in your local terminal session copy and paste commands without needing to change the variable.
export SITENAME=yoursitenamehere export GITHUB_TOKEN=yourgithubtokenhere export CIRCLE_TOKEN=yourcirclecitokenhere
SITENAMEwill be used as the machine names of the Pantheon site and the GitHub repo created in this process
GITHUB_TOKENlets Terminus interact with your GitHub account to create the repository
CIRCLE_TOKENis used to configure CircleCI to push to Pantheon any time a push is made to the GitHub repo
Use the Terminus Build Tools plugin to create a new Drupal 9 site from the Pantheon Drupal Recommended repository on GitHub:
terminus build:project:create d9 $SITENAME
Do not go to the web interface to continue installation. You now have a repository on GitHub containing your new site.
Clone a local copy to your
cd ~/projects git clone email@example.com:username/$SITENAME.git
Remember to replace
usernamewith your GitHub username.
Move into the local repository for your site:
Use Composer to install the Commerce Installation Profile:
composer config repositories.commerce_base vcs https://github.com/drupalcommerce/commerce_base composer require "drupalcommerce/commerce_base dev-9"
git statusto see that the
composer.lockfiles have changed:
Commit the new files and then push them to GitHub:
git commit -am "add commerce_base to project" git push origin master
Open your CircleCI Dashboard to see that tests are running on your new commit. After they pass, CircleCI will push the changes to your Site Dashboard.
Go to your newly created Site Dashboard. Under the Dev tab, click on Code, then install later.
You should now see your commit history. After CircleCI completes the automated tests built into our repository, it will commit the build assets and push them to Dev:
The Build Tools Plugin command you used earlier automatically installed Drupal's standard profile in the Dev environment for us. Now that you've installed the Commerce profile, you need that installed instead.
Use Terminus to run the Drush command
This will first clear the database of the Standard profile before installing Commerce. This Drush command requires that the system be in writable (SFTP) mode:
terminus connection:set $SITENAME.dev sftp terminus drush $SITENAME.dev -- site-install commerce
Review the last two lines of output to identify the username and password created:
Installation complete. User name: admin User password: jTHD8hd85U [ok] Congratulations, you installed Drupal! [status]
Log in to your Drupal site in the Dev environment. The presence of the Commerce button on the toolbar indicates a successful install:
What you do next is up to you and your needs. Consider reading our Composer Fundamentals and Workflows doc for more information.