Business Masochist

Learned lessons in setting up a Business Catalyst online business

Notes

BC Tip: nicer dialogs for the shopping cart

During various stages of product selection and checkout, Business Catalyst will pop up pretty ugly “alert” dialogs to draw the user’s attention to action performed or an error:

Standard Javascript Alert

Personally I find these pretty ugly. They don’t gel at all with the style of the site, and call me picky, but what’s with the pluralisation! It takes about 10 seconds (I timed it) to write the tiny amount of Javascript required to do the right thing. You know, 1 item , 5 items etc.

While the online wiki does contain info on suppressing these dialogs, I’m not sure that’s a great move, since important error messages are shown via the alerts.

Here’s how to replace the standard alerts with something nicer from jQuery UI (and fix that pesky pluralisation along the way):

jQuery UI Dialog

Step 1: Make jQuery available in your site template

To do this, put these lines in the <head> section of your site template HTML:

    <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

(Yes, you can host these CSS and javascript files locally on your site if you want to, but using Google’s CDN is reliable and doesn’t impact your BC quota).

Step 2: Set up a modal dialog for the page, and override the alert function

<script type="text/javascript">
   var cartupdatedialog;
   var itemsAddedRE = /([0-9]+) item\(s\) added to your cart./;

   $.noConflict();
   jQuery(document).ready(function() {
        setupShoppingCartDialog();
   });

   function setupShoppingCartDialog() {
        cartupdatedialog = jQuery('<div></div>').dialog({
        modal: true,
        autoOpen: false,
        draggable : false,
        resizable : false,
        buttons: {
            Ok: function() {
                jQuery(this).dialog('close');
            }
        }
    });
  }

  /* replace standard alert boxes with something nicer from JQuery UI */
 alert = function (msg) {

    var match = msg.match(itemsAddedRE);
    if (match) {
       var quantity = match[1];
       msg = quantity + " item" + (quantity == 1 ? "" : "s") + " was added to your cart";
       cartupdatedialog.dialog("option", "title", "Thanks!");    
    }

    cartupdatedialog.html("<p>"+msg+"</p>");    
    cartupdatedialog.dialog("open");
 }

</script>

That’s it. If all goes well, you’ll now get pretty dialogs instead of those standard javascript alerts.

Taking it further

Styling the dialog

The beauty of jQuery UI components is that they can be styled to your heart’s content to fit the theme of your site. The style was imported in the first line we added above:

    <link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css">

You can use this as a starting point to customise the look, or jump onto theme roller to build a new theme or browse existing ones.

Error and other messages

In the alert replacement function, I’m only looking for “item added” messages. Obviously BC can produce plenty of other messages. These will all render ok in the new dialog, but you may want to do something special depending on the message (like I did in fixing the pluralisation). For example you might look for error strings (e.g. ones starting with “ERROR”) and change the look of the dialog accordingly. Might make that the subject of another blog post.

Caveats

At this stage I’ve only tested this in newish browsers (Chrome, Firefox and Safari), but it should work fine in IE7 and IE8.

Notes

And so we chose Business Catalyst

I started this blog to document the process of taming the beast that is Business Catalyst. Having selected finally selected BC for our online shop, we threw ourselves at it with plenty of enthusiasm, glad to be finally getting on with the process of getting an online store.

Very shortly into the process of getting our store set up, we started to peel back the glossy veneer of BC marketing, to reveal a maddeningly strange beast under the hood. This blog is mostly therapy for me - but in allowing me to document some of the triple-reverse-pike hacks I’ve resorted to in order to get a site I’m happy with, I’ll hopefully provide some useful tips and trips for other BC victims. I mean customers.

What this blog is not

I’m not going to provide an exhaustive tutorial on setting up a BC store. You can find those elsewhere. Actually you can’t - what you will find is a hodge-podge of aging documentation, forums, knowledge bases and video tutorials spread across several websites.

How did we get here?

I dont’ really plan to document our process of arriving at BC for our online shop, apart from this brief decription:

At $39 a month, Business Catalyst is seems like attractive proposition for a small business looking for a one-stop-shop hosted ecommerce platform.

We had looked at many alternatives, and settled on Business Catalyst for a number of advertised reasons:

  1. a decent product / shop schema. Too many other shopping cart / eCommerce platforms seemed to be limited in strange ways. Like, the number of categories a product could belong to, or not supporting product variations, or limiting the number of products per category, or not allowing subcategories…
  2. being hosted, we don’t have to worry about staying up to date, or applying security fixes etc. In many “open-source” cart systems, keeping up-to-date with the latest security fixes seems to involve constant vigilance of user forums where various patches and individual file updates are posted on epic “read this now!” threads. Often these combined adhoc patches and updates can supercede released versions of the software by years. Someone should introduce these people to configuration management.
  3. direct payment integration with an Australian Bank (no gouging “gateway” middlemen)
  4. “complete” control of HTML and CSS of the site. In quotes, because inevitably this turned out to be far from the case.
  5. no lock-in. Well, not much lock-in. We’re obviously investing in the platform, so there will definitely be a cost in moving in the future, but we haven’t signed any lengthy contracts either.
  6. various other reasons I forgot.

So where is your site?

When the site gets a bit further along, I will reveal it, but its still in its very early stages now.