4th March 2010

Magento comes with a set of email templates. There are rather a lot of them, as there are a lot of reasons for Magento to send e-mails.

There is a problem though: none of them are designed for real-world use.

The problems with the default templates are multiple:

  • Many contain default text for the “Acme Shop” with hard-coded phone numbers of the Magento offices.
  • Many rank very highly as SPAM and usually don’t get to their destinations.
  • HTML tags are not properly structured, leading to display problems on some email clients.

What I have done is fix these major problems with the default email templates and present them here for download. These templates are as close to the originals as possible, while still solving the above problems (better at getting through SPAM filters, no “test site” text hard-coded, etc.)

email.zip

The place to upload this template set is into your default locale. I drop the “email” folder with all its contents into app/locale/en_GB/template/ – you may have a different locale set up. Don’t forget also to update your shop logo in the skin you use, under images/logo_email.gif

The email templates can be over-ridden in the database through the Magento administration screens, but it is a cumbersome process and I would not recommend it. It is far too easy to miss out a template or two.

Now, you can also make the job of managing the templates a little easier using the Email Template Adapter plugin. This template set already contains comment markers that split it up into container/header/middle/footer. You can over-ride these sections across all the templates using this plugin, without having to manually edit each individual email template. This comes into its own when you are running multiple store fronts, since each store can use a different wrapper – with its own logo, style, colours and introduction on – but still based on the core set of templates.

Feel free to download and use these templates. Any problems or suggestions, please let me know. If you would like us to construct formatted e-mail templates for your new shop, then please contact us for a fixed or hourly quote.

7th February 2010

Many applications I work on require the reading and parsing of third-party XML streams. These streams often originate with user-entered data and subsequently end up with invalid characters in. Of course, this should never happen, but it does and when it does, you need to be ready for it.

It surprised me to learn that not all valid UTF-8 characters are in fact valid in well-formed XML. So with a combination of this fact, and with remote applications allowing user-entered non UTF-8 data into the stream, I wrote the following function to clean up the data.

It is self-contained and simply allows through valid UTF-8 ranges, and blocks characters that are not in those valid ranges. These include non-printable control characters (except newline and linefeed), extended ASCII (which it attempts to transform to UTF-8) and other Unicode ranges that have been declared not-for-use.

<?php
/**
* Name: clean_utf8_xml_string
* Purpose: to remove or transform bytes or characters in a UTF-8 stream that
* will cause problems when parsed as XML. Not every UTF-8 character is a valid
* XML character.
* Author: Jason Judge
* Licence: GPL V3
* Created: 2010-01-07
*
* Takes a UTF-8 string and replaces any character that is not valid in an XML document.
*
* Note this does not require PCRE unicode libraries, which are often a problem on hosted
* servers.
*
* Inspiration taken from http://stackoverflow.com/questions/1401317/remove-non-uft8-characters-from-string
*/

function clean_utf8_xml_string($matches)
{
// This part handles the callback.
if (is_array($matches)) {
if (isset($matches[1]) && $matches[1] !== '') {
// Compatibility characters.
// Return as-is for now, but could map it to another character.
return $matches[1];
} elseif (isset($matches[2]) && $matches[2] !== '') {
// Valid UTF-8 for XML
return $matches[2];
} elseif (isset($matches[3]) && $matches[3] !== '') {
// Invalid single-byte characters.
// Instead of removing these, we can assume they are another character set and map them.
// Assume they are ISO8859-1 for now, but this could be parameterized.
return iconv('ISO-8859-1', 'UTF-8', $matches[3]);
} elseif (isset($matches[4]) && $matches[4] !== '') {
// Control characters - no mappings - so return a replacement character.
// You may wish to return something different, or nothing at all.
return '?';
}
}

// This part handles the first instance.
if (is_string($matches)) {
return preg_replace_callback('/'
// Ranges recommended to avoid - "compatibility characters".
// See http://www.w3.org/TR/REC-xml/ for the character ranges.
. '([\x7F-\x84]|[\x86-\x9F]|[\xFD][\xD0-\xEF]|[\x1F\x2F\x3F\x4F\x5F\x6F\x7F\x8F\x9F\xAF\xBF\xCF\xDF\xEF\xFF\x10][\xFF][\xFE\xFF])'

// Broad valid UTF-8 multi-byte ranges.
. '|([\x09\x0A\x0D]|[\x20-\x7F]|[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3})'

// Invalid single-byte characters which are likely to be extended ASCII and may be convertable to UTF-8 equivalents.
. '|([\x80-\xBF]|[\xC0-\xFF])'

// Fall-through - whatever is left, which should be single-byte control characters.
. '|(.)'

// If this is used as a static method, then replace __FUNCTION__ with __CLASS__ . '::' . __METHOD__
. '/', __FUNCTION__, $matches
);
}
}

?>

It is downloadable here:

clean_utf8_xml_string.php

6th February 2010

nlite logoI came across this neat Windows application today. It is basically a tool for creating customised Windows installation disks.

I’ve seen similar tools for slip-streaming service packs into disks, but this one goes a step further and makes it dead easy to include drivers and various other Windows tweaks. It is all very straight-forward to use:

  1. Point it at the original Windows disk.
  2. Tell it what you want to change (point it at service packs, drivers, etc.)
  3. Tell it to generate an ISO.
  4. Press GO.

The application will then spit out an ISO image that you burn to CDROM. I’m sure there are ways to install it over the network without burning a CD too.

I found it while looking for a way to reinstall XP onto Dell machine with a SATA device that the default Windows disk did not recognise.

nlite – http://www.nliteos.com/ – a great application for your toolbox.

27th January 2010
affilliates-for-all-website

The Affilliates For All website reflects the no-nonsense look of the application

If you run a Magento shop, and you would like to drive customers to your shop, then an affiliate programme may be one option to look at. This is basically low risk and low cost, since you only pay when you make sales.

The Affiliates For All Open Source application is able to support the running of your affiliate scheme.

Your affiliates would register on your site, through this application. Your only involvement would be to approve their application, and I guess attract these people in the first place by telling them about your scheme.

You can then provide the affiliates with a bunch of banners – it that’s your thing – or leave it up to them to create their own, which probably won’t be their thing, so do create the banners you want associated with your shop. The affiliates are provided with a snippet of HTML that they paste into their own website. The HTML contains a link back to any page of their chosing on your shop (remember, it is the affiliates’ job to decide how to send traffic your way, so long as they are not breaking any rules you get them to agree to on signing up).

All links back to your shop are then recorded against the originating associate, and all orders placed by visitors using those links are also recorded against the originating associate.

The application provides administration tools for calculating the orders-based commission and for paying the associates through PayPal.

As an application it is simple, and sticks to doing its main job (and main job only) without any fuss or eye candy, and it appears to do it rather well.

I don’t know why I have not come across this project before – most likely because the more commercial affiliate programmes have buried it somewhat. It is well written, well supported and has some excellent documentation written in some of the clearest English I have seen for a long time.

It is just writtem for Magento Commerce, and includes a plugin to handle cookies and order recording at the Magento end. With a little help, it may also be possible to expand the project to support other commerce systems too, but that all depends on demand and the help offered to the author, Pete Chown.

When I get this thing set up, I’ll report back on how it goes.

Tags: , ,

18th January 2010

The latest craze for designers seems to be redesigning airline boarding cards (and/or websites). Dustin Curtis started this off a little while ago, after wondering why American Airlines’ website is so difficult to use. Being proactive, Dustin redesigned the site and sent it (with an impassioned letter) to AA. This started a conversation with their web developer which is quite revealing about large organisations and their difficulties in bringing about change.

Delta Airlines existing boarding pass

Delta Airline's existing boarding pass

This inspired Tyler Thompson to have go at redesigning the Delta Airline boarding pass. Tyler’s designs look great, a across between movie poster lettering and art deco, although they don’t take into account some of the realities of boarding pass printing. Tyler invited others to create their own designs and he lists some of these in the updates at the bottom of the page. A couple of notable examples are shown below.

Tylers redesign

Tyler's redesign

Timoni Grone addressed the redesign in a more practical way, ie. acknowledging the limitations of the current printing techniques and typefaces available in thermal printing machines in airports.

Timonis redesign

Timoni's redesign

But this is my favourite, as it is so conversational and simple:

This one looks good!

Graphicology’s boarding pass redesign

So, since they’re getting so much free design advice, it will be interesting to see if any airlines actually want to improve their customers’ experience …

Tags: , , , ,

« Previous Entries