Knowledge Base/Store Administration/Creating Rules

Customer Behavior Rule - Triggers - Birthday Points

Sherrie Rohde
posted this on March 30, 2012 14:42

This trigger happens when a customer's birthday has occurred. This only works if the customer has specified their birthday.

Setup

Follow these steps to add the birth date to your store's signup form:

Magento Community Edition

  • Backend > System > Customers > Customer Configuration > Name and Address Options > Show Date of Birth

Magento Enterprise

  • Customer >> Attributes >> Manage Customer Attributes >> dob
    Show in front end >> Yes

Selecting options; optional or required, will cause the date of birth option to be available to customers while signing-up.

A note about security

Safety guards are already in place which prevent customers from receiving extra points if they change their birthday. Customers can only earn points within 365.25 days. at a time.

Notification e-mail

The Sweet Tooth configuration contains the configuration option to change and customize the notification e-mail that gets sent to the customer when it is their birthday and they have been awarded.

Notes for Magento 1.5.x Users

There is a bug in Magento 1.5.x (CE and equivalent Pro/EE editions) that causes the validation field of the customer birthday date to not validate with Javascript properly for some dates. This was resolved by Magento in Magento Community Edition 1.6 alpha1 and newer.

Hot fix for Magento 1.5.x

This unofficial, unsupported hotfix will temporarily fix the problem until you upgrade your Magento store to the latest version. Just replace line 437 in your js/varien/js.js file with the highlighted replacement:

/js/varien/js.js
this.year.setAttribute('autocomplete','off');

this.advice.hide();
},
validate: function() {
var error = false, day = parseInt(this.day.value.replace(/^0*/, '')) || 0, month = parseInt(this.month.value.replace(/^0*/, '')) || 0, year = parseInt(this.year.value) || 0;
if (!day && !month && !year) {
if (this.required) {
error = 'This date is a required value.';
} else {
this.full.value = '';
}

Missed Birthday Awards

In Sweet Tooth 1.6.0.4 and lower, some customers would miss out on their birthday points when they were supposed to be rewarded. A fix to this has been included with 1.6.0.5, along with diagnostic tools to check if any of your customers did not earn birthday points on their birthday. This tool will also allow you to automatically award the proper quantity of points to all those customers at the click of a link. You can run these diagnostics by logging into your Magento Backend, then going through the menu to "Rewards" > "Configuration" > "Other Configuration", then clicking the button found at "Diagnostics & Support Tools" > "Run 'Test Sweet' Diagnostics". You can then find the results of the test under the heading Check birthday points.

Technical details

In order to check if customers have earned their birthday points, Test Sweet gets a list of all active birthday points-rules, then goes through each year since the rule's start date until its effective end date (which is either the rule's actual end date or the present date, whichever is earlier), then checks each customer whose birthday falls within that span. This determines the number of the birthdays for which the customer should have been rewarded. Then, Test Sweet gathers all birthday points-transfers for the customer that appear to be for that rule, and if the customer has fewer transfers than they have had birthdays, that means one or more of the birthdays did not successfully earn points.

This behaviour was caused by an attempt to access a block from the context of the cron. Birthday points are checked each day using the cron, which does not include a controller action context since there is no controller action involved with it. The standard method of instantiating a block (through the controller action) failed and ended the cron process before points could be awarded. The block was being accessed to compile a points string to display the earnings to the customer in an email. We now instantiate the block through the core layout object, which is always available, regardless of context.