To App or Not to App?

I started to answer this question with a discussion of my own motivations for module development. They are many and varied, but they pretty much all come down to me either having an idea and some time or me getting paid to make time for an idea. However, I realize a person's motivations for writing his or her intangible "Drupal App" don't really matter if a particular motivation can co-exist with the existing model of community module development (whether it's evil or not, ignored or not, mirrored or not)... and ultimately I didn't want to do Robert's problem solving for him on what that could look like.

I then decided to take the angle of problems with the architecture of Drupal modules vs. an App store model, current support and maintenance channels, and a host of other problems I see with the idea of Drupal apps. Some points were established elsewhere... Yes, we can't really sell modules. Yes, people are selling themes. But no, I don't think selling "Features" would work... or at least I don't think it would be good for the consumer.

The traditional "App" (I hate that word - really? are we selling full applications?) must encapsulate its functionality, and it can't be effectively supported if its innards are free to be customized and mixed in with (i.e. broken by) other modules. This lack of interoperability between paid plugins on other platforms was actually quite a shock to me at last year's CMS Expo and is a big weakness. It also increases the development burden on the "App developer" making it a net loss for the consumer and provider. (Really, I saw an e-commerce plugin baking in its own Views system.) In fact, the only person I see getting a good deal is the "App distributor."

But I digress... these are just software / social engineering problems. If distributors really wanted developers and consumers to buy into their distribution models, they just have to provide solutions for these things. Once again, I'm not trying to do anyone's problem solving... unless they want to cut me in on their good deal.

What an App Store won't solve

I think other threads of this conversation have been dealt with adequately elsewhere, and overall I think an App store could work if all caveats are accounted for and the store's success is mitigated enough by the strengths of to not blast holes in the community development model we currently have. One thing I don't see getting a lot of play in the discussion, though, is whose problems an App store wouldn't solve. I've been thinking about this since taking part in the discussion with ICanLocalize (sorry, can't find the link).

A paid distribution channel will not provide you with the time or money to code or support your module. You still have to make the initial investment in time or money to get your "App" written, and long before you're turning a profit you'll need to be proving your intent and ability to support your product. If you then rely solely on distribution fees to recover your investment, you're relying on the wroooong license to get 'er done. If you intend to bundle support and maintenance with the distribution, I just need to point out again... this is first and foremost a good deal for the distributor unless he turns your App into Angry Birds.

Really, though, this is freaking Drupal... all we need is for enough interested people to build an installation profile for paid module support. Does that mean every module's support would go behind a paywall? I sincerely doubt it, as again, developers still have to prove their competence to support their project to non-paying new customers to convert them in the first place. They're also not the only ones who support modules on d.o... every one of their users is a potential support provider.

I do think that publicizing intentionally scaled back support in the absence of a paid distribution channel is not a good way to win hearts and minds. You don't have to say it, just do what you need to make money and offer premium support for people willing to pay for it. There are also other ways to build support around your module in the community, whether it's a bug squad or a sponsored development sprint.

Leaving module developers behind

Finally, something that just hit me... the only "Apps" I see as being viable at present are SaaS plugins and themes (thanks to licensing opportunities). Others see distributions and Features-esque configurations as viable. Perhaps there are still other viable options, but at the end of the day, none of this translates into dollars to fund the module development that any of these products depends on. And isn't that what started the conversation in the first place? Are we trying to figure out how to support module developers, or are we looking for a different way to make money using Drupal + contributed modules beyond professional services?

Drupal Commerce Alpha 4

Well, Christmas is already over for a lot of you, but there's still an hour left here in the States for me to wish everyone a Merry Christmas with a Drupal Commerce Alpha 4 release. I drove down to Louisiana to celebrate with my wife's family, and for once I took the passenger seat and got a good bit of work in to tighten up our Entity / Rules integration. Éowyn had a meltdown after 8 hours, too, so thanks to the Super 8 Motel in Wheatley, AR, I made even more headway on the dynamic Add to Cart form and its dependent attribute display.

However, integration and maintenance issues aren't the most exciting things in this release. I'm much more excited to announce the extensive work done on Drupal Commerce's Rules powered dynamic pricing system. We now have a centralized system empowering site builders and store administrators to implement pricing rules for discounts, tax calculation and display, and currency conversion through the user interface. While some of the subsystems still need attention, the Rules are in and working on the Calculating the sell price of a product event. You can see the results immediately on product field displays and in the shopping cart.

For example, I might want to give members to my Wombat Dating site a 10% discount. Never mind the absurdity of the scenario (if that's even possible) and see the basic product display node showing the product image and price fields:

The price field is displayed with the Formatted amount display formatter, which knows that modules are enabled that allow for dynamic price calculation:

This particular calculation option allows product sell prices to be calculated through Rules, so I've setup a 10% Members Discount using this simple rule configuration:

The end result, as you would expect, is a much cheaper night out on the town with our lovely wombat:

This system is a huge step forward from what we attempted in Ubercart, which lacked a baked in UI, touched every price on the site, and involved a pretty heavy caching system that couldn't address the problem of executing queries based on calculated prices. The system eventually got the boot, but we got a chance to tackle the challenges afresh with Drupal Commerce. Through some good discussion at DrupalCon Copenhagen with Damien, Miro Dietiker, and others, we realized the problem was actually in how we understood our dynamic pricing needs.

The first thing we did was restrict our initial scope to calculating product sell prices. That solved a lot of performance problems and API confusion on its own. However, we still had to solve the querying problem since we're depending on Rules to perform the calculations. This means we require PHP to execute to find the actual sell price of a product for any given customer. Simple queries that order and filter lists of products based on the sell price would be inaccurate once the price was altered for display, so a customer with a special discount on a product won't see it at the top of a catalog View when he orders by price. We've run into this problem several times at Commerce Guys, especially when displaying prices with tax included.

What we determined was that we needed to pre-calculate dynamic prices so the data would exist in the database before a customer ever needed it. Since we know the Rules attached to the price calculation event, we can pre-calculate prices for every combination of applicable Rules. The pre-calculated price data can then be joined into queries for any given set of Rules, enabling ordering, filtering, and faceting to work with actual sell prices instead of just the base price stored on the field. There are some guidelines to follow when constructing Rules for pre-calculation, and we've also devised a few simple ways for larger sites to keep the calculated price table from breaching epic row counts.

If I lost you, my apologies. It's very exciting stuff for the project, and I tend to talk too much about it. I've already explained it to all of my in-laws, including my 75 year-old grandfather-in-law whom I'll be teaching Drupal while I'm down here for his personal website.

I'll be blogging more about the dynamic price pre-calculation system, especially once it gets an actual user interface. For now it's a small API and a database table, but it's itching to be put through its paces. I'll be testing it first with Views and welcome additional eyes on the code. For more information on how it functions, refer to the development specification and the copious amount of comments on the pertinent functions in the Product Reference module.

Anyways, I've been closeted up with the laptop enough for one Christmas, so I'm going to join the rest of the family with some doctored eggnog and a seat in front of the fire. I hope you all had a Merry Christmas, and I look forward to feedback on the new hotness in Alpha 4.

Check out the release notes for the full changelog since Alpha 3, If you're thinking of resolving to visit Paris for the New Year, check out the details on our Paris Commerce Sprint, January 17-21, 2011 and consider joining us in Paris to push this code from a planned beta to 1.0 in time for DrupalCon Chicago. We'd love to have you.

Win an LCD TV on a new Drupal site

A friend of mine regularly produces quality Drupal sites with good write-ups on d.o, often finding his work featured on the front page of the site. He's drawn a lot of good feedback and given out a fair bit of advice to new Drupallers. A couple of his previous sites include and (with an iPhone app to boot!).

His latest website is a web magazine providing LCD TV reviews and news. I'm a little late to be writing about this (honestly, I thought I had till the end of the month for some reason), but the site is running a competition for Black Friday giving away a free Samsung 40" LCD TV. If you read this tonight, go ahead and go sign up for your shot to win and spread the word.

While you're at it, you can poke around the site to read more about LCD TVs, read reviews from other site members, and provide feedback on TVs you own or have owned. I'm still in the stone age on a 21" CRT myself, so adding a new TV to chez moi would be most welcome. Wink

Drupal Commerce Alpha 3

This last week's development on Drupal Commerce has been a flurry of exciting commits for me. Ever since the first demos I've been talking about how the Add to Cart form will be able to use field data to let customers choose products by their field values instead of their titles. Similarly, I've talked about dynamically updating field data on the page so images, prices, and other fields are re-rendered to reflect the currently selected product.

Until now these features have been relatively low priority, as we focused on the other major core systems. However, with the release of 7.x-1.0-alpha3, they have finally moved from the hypothetical realm into code awaiting your testing.

Example Add to Cart form
Inherited product fields, dynamic options, and dependent attributes... oh my!

The screenshot shows three features of Drupal Commerce product displays:

  1. Product fields from the default product are pulled into the node display via the Product Reference field. The pictured display actually references 12 separate products representing different color / size combinations.
  2. The Add to Cart form display formatter turns product reference fields into forms. It creates attribute select lists using field data from the referenced products, only including options that actually exist on products referenced by the field.
  3. As options are selected on the form, the product fields displayed on the page are updated to reflect the currently selected product. The options on the form also update to show newly available options, allowing for attribute dependencies to any depth in their order of appearance on the form.

In other words, as I choose a color option, the size select list updates to only list sizes of the shirt available in that color and the image can change to show me wearing a different shirt. If the size is changed to a more expensive option, the price on the page updates accordingly. I'm sure this description hardly does the features justice, so I'll get a screencast and live demo up next week for you to play with.

This behavior is all thanks to the new #ajax property in Drupal 7 and required no custom JavaScript to work. When a select list's value changes, the form is submitted and rebuilt server side giving me a chance to change the available options. My #ajax callback uses a set of AJAX commands to direct the replacement of the existing form with the newly rebuilt form and works alongside the product reference field to re-render and replace any product fields on the page as necessary.

(On a side note, if you need to do full form replacement yourself, be sure not to target the form using its id. Each time it is rebuilt, the HTML id is incremented by drupal_html_id(), so the replacement will only work the first time. Instead, either target a container within the form or some other selector that won't change each refresh. This cost me a few hours. )

Other features of note in this release include:

  • The order edit form has taken shape with vertical tabs, revision logging, and working customer profile reference fields.
  • All currencies have been defined with updates to the Price field accommodating multi-currency stores. Currency rounding now accommodates currencies like Swiss Francs, which rounds to the nearest twentieth (thanks to das-peter). Only known currency formats are implemented, so you may need to open an issue for yours to have proper formatting (i.e. $100.00 vs. 100.00 USD).
  • The Payment module received more work since the last release to support credit card payment methods. I've created Commerce Authorize.Net as a proof-of-concept and example implementation for other developers to follow. (Some code specific to that module right now will be abstracted to Payment, like a general handler for prior authorization captures.)

More information and a full commit log are available in the release notes. I'm very grateful for the efforts of community contributors, especially das-peter for his help on the currency issues and our Entity API and Rules integration.

There's still plenty of work to be done, so feel free to join is in the issue queue.