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 drupal.org 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.

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.

Drupal Commerce Alpha 2

Blog's been a bit sleepy as of late... so sleepy it managed to miss out on two trips to Europe for DrupalCon Copenhagen and E-commerce Paris 2010, the first Drupal Commerce alpha release, and my daughter's first steps and first birthday.

Éowyn looking up.
"What gives, dad?"

Does it work to just say they were all awesome and move on? My wife can testify that many things in my life back up to a point where a dearth of activity stymies said activity's resumption... or simply put, when I stop doing something I want to do for an extended period of time, I find it hard to start again.

Ok, </introspection>. I'm breaking the ice with a happy announcement - I managed to package up Drupal Commerce 1.0-alpha2 in the wee hours of the night.

The release notes provide an overview of changes with a full commit log since the alpha 1 at DrupalCon CPH. The new alpha and my development installation profile have been updated for Drupal 7.0-beta1, though I still need to update our Fields to take advantage of display formatter settings.

The highlights of the release are:

  • Functioning Payment module with integration points for on-site methods (demonstrated by the core Null payment module) and redirected payment services (demonstrated by PayPal WPS integration in Commerce PayPal). Payment service integrators would do well to jump on board so we can take care of any workflow issues, especially for redirected payment services.
  • SimpleTest base class for Commerce testing provided by Jeremy Blanchard, complete with documentation and related issues. It's just begging for you to start using it...
  • Updates to the price object to allow Rules based transformation of prices prior to purchase and/or display; still requires some implementation as outlined in a rambling Google Doc.
  • The Specification handbook at DrupalCommerce.org has received some love to get it up to speed. A major goal for the project was to not have undocumented major releases, so I've begun documenting the various system components and will then move onto the system overviews. For now only the sections on our info hooks and core API utilization have meaningful content. Feedback on the structure is most welcome.
  • A host of bugfixes and API / variable naming standardization. The documentation effort really helped here, so I expect similar results as I catalog the Commerce Entities and Fields.

The release is also accompanied by an alpha release of Address Field, a dependency the Customer module uses to collect name and address information during checkout according to the xNAL standard. This module took some massaging to get working, because it defines a Field that uses #ajax to update address form elements based on the country chosen. It now works no matter where I embed the widget, even if I'm doing something crazy like embedding the customer profile entity's field widgets in the checkout form... but that's a topic for a follow-up blog post.

That's all to report for now. There's plenty more activity and good contributions coming through the issue tracker. As this alpha's release was dependent on a fully functioning Payment module, the next alpha release will be dependent on the full implementation of dynamic pricing as outlined in the doc above. We'll also push to get as far as we can on the order administration UI and show some love to product and line item display in the meantime. We'll stay busy!

Pages