Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Headless Commerce for Drupal

Parent Feed: 

For many businesses, eCommerce is an increasingly important trend. With the potential for frictionless and simple exchanges, doing business on the web has never been more appealing to customers. To make eCommerce work for your business, though, our site needs to be robust enough to handle every step of every transaction.


drupal decouples commerce

Photo by Igor Miske

With its open source community and robust core, the Drupal platform is a worthy solution for any and all eCommerce needs. While a site built on Drupal will have the enterprise capabilities needed to handle a wide array of business needs, one of the major selling points of the platform is its flexibility. Drupal has the ability to be decoupled, allowing you to use Drupal as your background CMS while utilizing a third-party solution for your front end. If your brand is tied to an existing look or design, a decoupled or “headless” solution will let you have your cake and eat it, too.

As you might imagine, headless solutions have major implications for the possibilities of eCommerce platforms. At this year’s MidCamp, an annual meetup of the Drupal community in the Chicago area, Commerce Guys Product Lead Matt Glaman took a look at the future of headless commerce solutions. What emerged from the session painted a picture of progress, as developers are continuing to create solutions in Drupal that will power a wide array of eCommerce solutions.

Decoupled Drupal Facts & Myths

Leading the path toward making headless commerce more feasible is Commerce Guys, a Drupal software firm that held a couple of events at MidCamp on the subject. Best known for creating the Drupal Commerce module and the shopping-cart software Ubercart before it, Commerce Guys brought years of experience in the eCommerce space to this year’s event.

Offering a look at the technical side of Drupal-based eCommerce, Glaman examined the various challenges and solutions surrounding headless commerce. As he explained, the heavily structured data model of eCommerce in general presents a challenge, as do the relationships between the various layers in a site, such as the data and presentation layers. Making sure that the connections between the Drupal-backend and the myriad of frontend possibilities are robust and stable is essential to making headless commerce solutions work for users.

To address these challenges, Glaman highlighted a variety of existing API solutions. To enable headless commerce, the available options include the GraphQL data query language, JSON-RPC, JSON API and the RESTful Web Services spec. Though the latter two have the convenience factor of being included in Drupal Core, all of these solutions have their strengths and weaknesses in the context of headless commerce.

The efficacy of each solution varies depending on which stage of the eCommerce process you look at. For catalogues and product display pages, using the JSON API offers strong query capabilities but doesn’t support mixed-bundle collections. A GraphQL solution, on the other hand, supports cross-bundling but queries can become very large. Most existing solutions also struggle with “add to cart forms,” as it can be challenging to create reusable solutions. Overcoming that hurdle requires using solutions in concert, such as a GatsbyJS:React and GraphQL build. Finally, for carts, the JSON API requires integration with a Cart API, while the aforementioned query issues with GraphQL require the use of GraphQLMutation plugins to solve. For a deeper look into the nuances of these existing headless commerce solutions, you can watch Glaman’s full presentation here:

So, while headless commerce in Drupal is achievable, it takes some effort to get to a point where it can handle your business’ eCommerce needs. Luckily, the strength of Drupal’s open source community means that you don’t have to wait for the Commerce Guys to fix everything. A firm like Duo can help you fine-tune an eCommerce solution to fit your needs. Don’t just take our word for it; our previous work with the Chicago Botanic Garden demonstrates our prowess in designing unique and robust eCommerce platforms.

If you’re interested in exploring a headless commerce platform on Drupal or are just looking to make your online business run more smoothly, Duo is the right partner for you.

Explore Duo

Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web