Wednesday, September 19, 2018

Display Custom Text Message or Entity Fields on Standard CheckoutPages

Custom text messages or entity fields can be displayed on the checkout pages using Tag substitution and custom Javascript.

To display custom Messages or Entity fieldsat the Checkout pages:

1. Create a List of Messages.
   
a. Go to Customization > Lists, Records, & Fields > Lists > New.
    b. Enter a Name for the list.
    c. Input desired values tab at the Value tab. In this example, the values are Value 1, Value 2 and Value 3.
    d. Click Save.

2.
Create an Entity Field.
   
a. Go to Customization > Lists, Records, & Fields > Entity Fields > New.
    b. Label the custom field. For this example, the label is My Custom Field.
    c. Set Type to List/Record.
    d. Choose the List/Record created in step 1.
    e. At the Applies To tab, make sure only Customer is checked
    f. Display > Subtab = Main > Display Type = Normal
    g. Click Save
        Note: The internal ID of the custom field is used in the script. In the example above the internal ID is custentity12.

3. Create an empty Web Site Tag
.
    a.Go to Setup > Site Builder > Tags > New.
    b. Enter a Tag Label. In this example, EMPTYTAG is used.
    c. Leave Description and Default Value fields blank.
    d. Click Save.


4. Enter the EMPTYTAG in the custom Theme applied to the webstore.
   
a. Go to Setup > Site Builder > Themes.
    b. Edit the custom Theme applied to the webstore

    c. Click the Body tab.
    d. At the Content Area Template enter the following:

       <!-- start content area - Basic : Round Edges -->
         <TD valign="top"><TABLE><EMPTYTAG></TABLE><TABLE border="0" cellpadding="0" cellspacing="0" width="100%"></TABLE></TD>
       <!-- end content area - Basic : Round Edges -->

    e. Click Save.

5. Edit the
Checkout tab to enter custom Javascript displaying the Message. 
   
a. Go to Lists > Web Site > Tabs.
    b. Edit the Checkout tab.
    c. At the Tag Substitution tab select the custom tag that was created in step 3:
    d. Enter this code at the Substitute Value column.

        <script>
          var cust = "<%=getCurrentAttribute('customer','name')%>";
           if(cust != '')
           {
            document.write("<TD><H2>THIS IS A CUSTOM MESSAGE: <%=getCurrentAttribute('customer','custentity12')%></H2></TD>");
            }
        </script>

e. Click Save.

Note: The internal ID "custentity12" is used as an example. It can be different when a user creates a custom Entity field.

 

The custom message and the entity field value are displayed in the Checkout pages.

Note: This is currently filed as Enhancement 32972 - Allow custom messages to be placed on all pages of the checkout process in the webstore. 

No comments:

Post a Comment