Extending Drupal 7 Services into an E-commerce App
Article
By now, you’ve surely heard that Drupal 8 is pushing boundaries for users, content editors, administrators, and developers – if not, where have you been?
Obviously, not every site has the luxury of being able to migrate and adopt new technologies. If you are in the same position as me, then many of your clients – or indeed, the company you work for – have spent lots of time and money investing in Drupal 7; at this point, urging a new platform on them is probably going to fall on deaf ears. But all is not lost! Drupal 7 can still create a powerful RESTful Web Service API or a terrific mobile application.
So the old adage again rings true: “Where there is a Drupal 8 core initiative, there is a Drupal 7 contributed module.”
Having attended the Commerce 2.x sprint in Paris, I can safely say that if you do eventually upgrade to Drupal 8, it won’t be a massive undertaking molding your Drupal 8 Core services output to match that of Drupal 7 contrib services. Not all your work will be lost.
When I first started down the road of mobile apps, I was certain I did not have the time to learn Objective C and Java, as well as the intricacies of each mobile platform. (Sound familiar?) All I wanted was the ability to utilize the Drupal technology I already knew, and then enable PhoneGap without having to learn any device-specific language.
For purposes of this article, I won’t assume you know mobile apps technology nor much about Drupal’s Services module, REST, jQuery Mobile, Xcode, or PhoneGap. I do assume that you know Drupal, can work your way around the administration interface, and know some basic PHP and Javascript. With that in mind let’s take an overview of technologies you can utilize for your mobile application.
First, let’s install DrupalGap and its dependencies.
Now we have a core DrupalGap service and the basic service resources we might want for our mobile application. All the generic things we use on most Drupal sites are right there: resources are content-available for query through endpoints; and DrupalGap supplies us with a default endpoint.