I have been doing a lot of work lately in Adobe Business Catalyst. I am not sure that I would recommend this product to anyone, since there are many problems with the system and the lack of proper customer support. However, I don’t want to get into that now.
One of the problems that I have been trying to solve is as follows. Customer service at a company that I work for uses the same order entry system as the end user. The bring up the external website and walk the customer through the process over the phone. The problem is that we cannot track phone orders back to the referral source and therefore have no way of knowing the true number of acquisitions through adwords, for instance.
I wanted to add a checkbox to the check out form that asks if this order is customer service assisted. This checkbox should only show up for orders originating from the company IP address.
Here are the challenges:
IP Address
Getting the user’s IP address in BC is straight forward. There is a BC tag {module_visitoripaddress} for that purpose. However, I did not want to have our IP address visible in the code, so I included a hash function. The following code illustrates the approach using jquery:
String.prototype.hashCode = function() { if (Array.prototype.reduce) { return this.split("").reduce(function(a,b){a=((a<<5)-a)+b.charCodeAt(0);return a&a},0); } else { var hash = 0, i, chr, len; if (this.length == 0) return hash; for (i = 0, len = this.length; i < len; i++) { chr = this.charCodeAt(i); hash = ((hash << 5) - hash) + chr; hash |= 0; // Convert to 32bit integer } return hash; } };
Then insert the following in the $(document).ready function (replace the hashcode below with your own):
if("{module_visitoripaddress}".hashCode() == <hashcode for your ip address>) { $(".phone-order").css("visibility", "visible"); }
Attaching the field to an Order
The next challenge is to add a field to the order. First, we need to extend the database by going to CRM->Extend CRM Database, and adding a new CRM form. Put the additional fields into that form.
One thing that is not obvious in building a Business Catalyst site is that the Online Store Template for Registration – Buy uses a form defined in the Web Forms tab for submitting an order. So, to add another field to the order, you need to add the new CRM form to that web form (it may be called Check Out). From there, you can copy the field from the generated HTML into the Registration – Buy template and, Voila!, you have a new field in your order. Make sure to surround the new field with a div that has the phone-order class so that the above javascript will work.
(Unfortunately, the form HTML is not well formatted, so it is hard to find the right field. One way to fix this is to copy the HTML from BC and paste it into dirtymarkup.com and click Clean.)
Adding a Survey Post Order
You can also add more details to the order on the Receipt – Buy page after the order has been processed. The process is similar to above. 1. Create a new CRM form with the information you want to capture and, this time, make sure to apply this form to the Order entity in the last tab of the CRM form creation process. Because the form is submitted with an Order ID (&OID={module_oid}), BC will attach the data to that order. 2. Create a web form and copy the code into the Receipt – Buy page.