We have a long roadmap and even longer wishlist for what we want to see in Drupal Commerce. If we could double the productivity of the team overnight via AI adoption, we’d immediately apply the hours we win back to chipping away at that roadmap, and we would still find endless ways to improve the platform.I’ve been slow to try out AI tools even as they’ve grown in popularity. Part of it is the pedant in me bristling at the fact that we’re all now calling “AI” what we used to call “machine-learning” on “big data.” But I can get past that to admit that turbocharged predictive text generation applied to coding is actually pretty neat.Last week I turned up the need for a minor improvement to the Commerce Recurring module. This module defines a subscription entity type and a related entity trait that will create a subscription for a customer based on their purchase of a given product variation. The module supports a wide variety of use cases for subscription billing – pre vs. post-billed subscriptions, fixed price vs. metered usage, prorations, etc. – and it lets you determine the billing cycle based on fixed dates or rolling intervals.I’ve had a few “Aha!” moments while working in Cursor along with some natural frustrations. Before relaying the former, I can illustrate the latter. Cursor uses AI to make code suggestions in the editor based on what it thinks you want to do. Once it makes a suggestion, you hit tab to apply it, which means quickly roughing out a simple function is an exercise in whack-a-mole as it continually expands suggestions where you just wanted to indent. Easy enough to train myself around, but perhaps I can find a setting to make this less aggressive.I expect measured, intelligent application of AI to become a baseline expectation of Drupal service providers and contributors, and I’m curious to know what tools are producing the best results, particularly with respect to best practices adherence.We’ve opened the door internally for more experimentation with IDEs, models, and other tools that don’t replace the developer but augment his or her ability to deliver features faster. I’m interested in more complex patch development, test coverage, or whole feature development, especially in atypical languages or environments for our team (e.g., a Node.js based Stripe app for Drupal Commerce).The problem I discovered for our client was related to some unique administration requirements of their offering. Someone might susbcribe offline to begin using the company’s services immediately, but a CSR may not activate the digital component of their subscription for several days. Thus, when they actually create the order may not be when the subscription started, but Commerce Recurring was using the current time of a request to place a subscription order even when an administrator specified an alternate “placed date” for the order.$start_time = $this->time->getRequestTime();

I isolated the problem fairly quickly. Commerce Recurring used an order placed subscriber with the following code:if (empty($order->getPlacedTime())) {
$order->setPlacedTime($this->time->getRequestTime());
}

At the end of the day, this was a relatively minor acceleration vs. me making the change manually (if not as succinctly). However, it’s representative of how I believe AI can accelerate Drupal Commerce development, and it’s the kind of magical experience that helps developers get excited about its potential. The more context a model has, including your source code, your project’s best practices, and even the contents of your clipboard, the more capable a tool it is for predicting the code you want to write.Recently I’ve been exploring AI assisted development by switching from VS Code to Cursor and trying out different chat prompts and models while working on Drupal Commerce. I haven’t been tracking the myriad tools and models too closely, so I opted for the tool that required the least amount of change for me. All my extensions and my fine-tuned custom theme transfered over without issue, so I was happy to move forward with Cursor. ☺️

Similar Posts