Custom fields in the checkout

Additional custom fields can be added to the address collector (stage 2) and the page thereafter (stage 3). These fields are injected inbetween the address and the special instructions box.

This example adds an invoice reference field to the address collector:

1. Create or edit "stg2form.template" in the Back Office, Utilities, Templates section and add the following to it:

<span>Invoice Reference: [<tag id="txtInvRef" type="textbox" width="200" cssclass="NormalTextBox" maxlength="50"/>]</span>

Note - You can use many standard ASP field types and attributes. For example: type="textbox" TextMode="MultiLine" will create a text area instead of a single line input.

2. Create or edit "stg2formxml.xsl" and add the following to it:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<h3>Invoice Reference</h3>
<xsl:value-of select="genxml/textbox/txtinvref" />
</xsl:template>
</xsl:stylesheet>

Note that the 3rd to last line where it says "genxml/textbox/txtinvref" must be lower case!

3. You can use the token [Order:Stg2FormXML] to display the results of the field in the order templates - order.email.template and order.text.template. Simply add another table row somewhere suitable and insert the token and an appropriate label.

For example: "Invoice reference: [Order:Stg2FormXML]"

4. Variations
You can do the same as above, but on the payment page of the checkout instead, by replacing"
stg3form.template with stg3form.template
and
stg3formxml.xsl with stg3formxml.xsl
and
[Order:Stg3FormXML] with [Order:Stg3FormXML]

Examples from the forum

Last edited Jan 16, 2013 at 9:36 PM by robax, version 4

Comments

trouble2 Jul 23, 2012 at 8:46 AM 
Hi, Is it also possible to add multiple extra fields?
I've been trying to add 2 fields to stg3form.template and stg3formxml, however, in the output, it only shows the last field.

robax Feb 6, 2012 at 11:02 PM 
Thanks for that, I've updated the post. Note that we don't receive notification of comments in the docs like this, so it's just by chance that they are discovered. Post to the Discussions tab instead.

djebe Nov 30, 2011 at 10:58 AM 
Hi Rob,

I tried this example, but i bumped in to an error. If found out the what was wrong and
it seems that there is a small error in this documentation.

In the example code of step 1, the closing of the tag is incorrect.
<span>Invoice Reference: [<tag id="txtInvRef" type="textbox" width="200" cssclass="NormalTextBox" maxlength="50">]</span>

but it should be (the slash at the end of the tag)

<span>Invoice Reference: [<tag id="txtInvRef" type="textbox" width="200" cssclass="NormalTextBox" maxlength="50"/>]</span>