A Drupal e-commerce project
Drupal Commerce has been around for more than a decade. More than fifty thousand sites report using Commerce, and its maintainers have kept the suite of modules modern, flexible, and robust over the years for both Drupal 7 and Drupal 8/9 with the latest code for the Drupal 7 version released as recently as earlier this year.
The National Center for Employee Ownership (NCEO) came to us in 2018 with an existing investment in a Drupal 7 Commerce site that had thousands of hours poured into it in terms of configuration, custom development, and order management. At the time their staff were manually entering email and telephone orders into the Drupal Commerce backend, and were hoping to upgrade to a full-featured, payment gateway enabled online store. They also wanted to develop a brand new public facing NCEO.org that better captured their organization and connected users with their content.
At that time building a brand new public-facing website and upgrading an existing complex online store presented an interesting problem. Do we continue building on top of Drupal 7 knowing it will reach end-of-life in a couple of years? Or do we bite the bullet and invest in a new Drupal 8 solution with its promise of a future-proof approach to website development?
Spoiler alert — the answer was both.
Drupal 7 and Drupal 8: The best of both worlds
NCEO was using a custom Drupal 7 implementation of Commerce and RedHen CRM to manage nearly a thousand products, tens of thousands of customers, hundreds of thousands of order records, and complex coupon and membership pricing logic. Their existing platform represented an extensive investment — and their staff were already trained and proficient on the existing suite of tools. While the tides were definitely turning towards all things Drupal 8 in 2018, completely rebuilding the platform, migrating records, and training staff on a new system was a tough sell. And it was the wrong solution.
The right solution was to protect the existing investment, and building a lightweight Drupal 7 / Drupal 8 integration could do just that. Users needed to be able to browse NCEO’s content and products on a new Drupal 8 website, and then be seamlessly handed-off to a Drupal 7 Commerce backend to make payments or review order details. Luckily, Drupal’s architecture lends itself to just this sort of integration and synchronization across platforms.
A touch of tech
After extending NCEO’s Drupal 7 Commerce implementation to include an intuitive, turnkey customer checkout experience, all that was left to do was wire that backend to the brand new Drupal 8 NCEO.org that would roll out the following year.
The solution had to synchronize both users and products. The NCEO team would continue managing their products on the Drupal 7 platform, but those product updates would need to automatically post to the Drupal 8 site where users would browse them. Additionally, users would need to see their custom membership pricing on the Drupal 8 site, and maintain their session and membership data as they were seamlessly directed to the Drupal 7 platform for checkout.
Single sign-on & user data synchronization
We used the CAS module to create the “behind the scenes” single sign-on between the two sites, and to help synchronize the user role data that translates to special membership pricing and offers. When a user completes a membership purchase (on the Dupal 7 portion of the experience) their new user role is synchronized back to the Drupal 8 website — ensuring that they see the appropriate discounts and membership offers while browsing products, and later receive those discounts at checkout.
Product synchronization via the hook system
The NCEO team continues to manage products and customer records on the Drupal 7 portion of the platform. On the Drupal 7 side we built a simple webhook system that posts product update data using Drupal’s drupal_http_request($url, $options) everytime a product is created, updated, or deleted. We capture those actions with the insert, update, and delete node hooks available in the Drupal 7 API. In essence, every time someone makes a change to a product managed on the Drupal 7 platform, those changes are securely transmitted to the public facing Drupal 8 site.
When the data posts to the public-facing NCEO.org Drupal 8 site the products are updated almost immediately, ensuring that users are consistently presented with the absolute latest product information. Product updates on the Drupal 8 side are accomplished by defining a controller to accept data at a specific endpoint or URL — I wrote a pretty detailed post about capturing webhooks in Drupal 8 sometime ago, complete with code samples.
The integration is super lightweight and the end product is a seamless checkout experience. The solution lets the existing platform continue working as designed while rebuilding the primary public facing website with the more modern, evergreen Drupal 8.
Value before technology
As a developer there’s often an urge to design and build systems using the latest and greatest iterations of our favorite technologies. As the Director of Engineering at Aten, it’s important for me to consider how to achieve our clients’ goals in a way that’s cost effective, secure, and sustainable. Often that requires a mix of bleeding edge technology and creative out-of-the-box solutions that keep the people using the software at the center of the process.
In this case we were not only able to protect an existing investment while delivering a brand-new Drupal 8 website, but also built out a flexible architecture that will be super easy to upgrade in the future. In place of a Drupal 7 Commerce and RedHen CRM backend, NCEO could easily drop in another customer records solution to plug into their Drupal 8 site and store — all with hardly any changes to the Drupal 8 side. Even now in 2021 the solution works great — and as Drupal users everywhere decide what to do with their Drupal 7 assets, NCEO is in a great place to consider next steps for the commerce administration aspect of their platform without having to think about a complete website rebuild.
Interested in learning more about what innovative digital solutions can do for your organization? We’d love to hear from you.