fromSeptember 2014
Article:

Extending Drupal 7 Services into an E-commerce App

Don’t Wait for Drupal 8
0

Shopping Cart DesignBy 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.

DrupalGap also supplies us with a mobile toolkit to get us started with PhoneGap. By following the installation instructions for PhoneGap and DrupalGap, we can quickly be set up with a mobile application that allows user login, node CRUD, and taxonomy CRUD – all out of the box and without writing a single line of objective C or Java. Pretty impressive.

However, as a “Commerce Guy,” I always want to take technologies deeper into the sphere of e-commerce; if I can offer my clients an extra route to market they are usually all ears.

Taken together, PhoneGap and DrupalGap can be brought into Drupal Commerce, and Drupal Commerce has a contributed module that extends the list of services resources shown above. This allows us to import our products, orders, and line items into our newly-built mobile application. The Commerce Services module gets you what you need. DrupalGap even has a companion module to get you set up with a native mobile e-commerce app.

My session in Austin with DrupalGap maintainer Tyler Frankenstein went into great detail about setting up with it. The most difficult part is payment: How do you remain PCI compliant while using Services? Thankfully, a number of payment gateways are solving this problem: for example, Stripe, for which there is a contributed module for both DrupalGap and Commerce.

So there you have the toolset: not only a Mobile Application Development Kit and API for standard mobile apps, but an extra gift to easily turn your Drupal Commerce site into a native mobile app.

There remains the question of why? Why would you want a native mobile app for your e-commerce store?

Well, not only do native apps have capabilities not available to HTML apps or responsive websites – like push notifications and background downloads – but you should also consider the different modality and usage of the mobile devices.

This means that the real opportunity is not to just clone the website into something like PhoneGap, but to redesign it so as to leverage new-use cases (e.g. while on the go for mobile, and while at home for tablets). Think of the possibilities of offering your mobile customers discounts while they’re in a competitor’s retail store (which you know thanks to geolocation), letting them view photos and reviews, or upload their own photos, using their device’s camera.

The possibilities are considerable.

Drupal Developers, let’s not sell ourselves short; extend Drupal power from websites into the world of apps!

"Apps are just (better) websites, because they don’t have to give a damn about SEO. Remember when we used to have web pages that were for users, not spiders? Keywords everywhere drives me bananas.”
Michael Arrington

"shopping cart" by hospi-table is licensed under CC BY-SA 2.0

Advertisement

From our blog

Entity Storage, the Drupal 8 Way

In Drupal 7 the Field API introduced the concept of swappable field storage.

The Drupal 6 to 8 Upgrade Challenge - Part 2

Having concluded the readiness assessment, we turn next to migrating the content and configuration. In reality, there’s little chance that we would migrate anything but the blogs from our old site. For the sake of giving Migrate in Core a workout with real conditions, however, we’re going to upgrade with core’s Migrate Drupal module rather than rebuilding.

The Drupal 6 to 8 Upgrade Challenge - Part 1

Nathaniel Catchpole , the Drupal 8 release maintainer and Tag1 Senior Performance Engineer, suggested that Drupal shops everywhere could support the

DrupalCon Austin

The entertainment industry is not for the faint of heart.

Drupal Watchdog Joins the Linux New Media Family
Drupal Watchdog 6.01 is the first issue published by Linux New Media.

Drupal Watchdog 6.01 is the first issue published by Linux New Media. Come see the Drupal Watchdog team at DrupalCon 2016!

Drupal Watchdog was founded in 2011 by Tag1 Consulting as a resource for the Drupal community to share news and information. Now in its sixth year, Drupal Watchdog is ready to expand to meet the needs of this growing community.

Drupal Watchdog will now be published by Linux New Media, aptly described as the Pulse of Open Source.

Welcome to DrupalCon Barcelona - The Director's Cut

For all you schedule-challenged CEOs – and ADHD coders – this Abbreviated Official Director’s Cut is just what the doctor ordered.

Welcome to DrupalCon - The Barcelona Edition

Did we have fun in Barcelona?
OMG, yes!

Did we eat all the tapas on the menu and wash them down with pitchers of sangria?
Yes indeed!

Recursive Closures and How to Get Rid of Them

This came up while manipulating taxonomy children and their children recursively, so it’s as not far from Drupal as you’d think.