Skip to main content
Last Reviewed: December 13, 2022

Drupal Commerce on Drupal

Use Composer to Install Drupal Commerce with Drupal, on Pantheon


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

Before You Begin

  1. Make sure you have updated to the latest version of Drupal

    Info:
    Note

    Drupal 8 reached end-of-life status in November 2021, and is no longer supported by Drupal. Read the official announcement on Drupal.org.

  2. 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.

  3. 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
    • SITENAME will be used as the machine names of the Pantheon site and the GitHub repo created in this process
    • GITHUB_TOKEN lets Terminus interact with your GitHub account to create the repository
    • CIRCLE_TOKEN is used to configure CircleCI to push to Pantheon any time a push is made to the GitHub repo

Create a New Drupal Site

  1. Use the Terminus Build Tools plugin to create a new Drupal 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.

  1. Clone a local copy to your projects folder:

    cd ~/projects
    git clone [email protected]:username/$SITENAME.git

    Remember to replace username with your GitHub username.

Install Drupal Commerce

  1. Move into the local repository for your site:

    cd $SITENAME
  2. 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"
  3. Run git status to see that the composer.json and composer.lock files have changed:

    Git Status showing updated Composer files

  4. Commit the new files and then push them to GitHub:

    git commit -am "add commerce_base to project"
    git push origin master
  5. 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.

  6. 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:

    Build Assets on Dev

Reinstall Drupal

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.

  1. Use Terminus to run the Drush command site-install.

    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
  2. 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]
  3. Log in to your Drupal site in the Dev environment. The presence of the Commerce button on the toolbar indicates a successful install:

    Drupal Commerce in the Toolbar

Conclusion

What you do next is up to you and your needs. Consider reading our Composer Fundamentals and Workflows doc for more information.

More Resources