Setting Up Custom Transaction Body Fields
Set up custom transaction body fields to appear in Checkout and My Account. This requires setting up the custom transaction body field in NetSuite and overriding the correct template to render the information in your web store.
To set up a custom transaction body field:
-
In NetSuite, set up the custom transaction body field. See Creating Custom Transaction Body Fields for details.
For a custom transaction body field to render in your Commerce website, note the following:
-
Create a Label and ID for your custom item. If you do not specify an ID, NetSuite will create one for you. Use these when configuring your site and customizing templates.
-
Check Sale and Web Store (Applies To subtab).
-
SCA supports the Mandatory option in the Validation & Defaulting subtab, but as information only. Transaction body fields are not validated in the frontend (client side). If a custom transaction body field is setup as mandatory, the field will be required for Quotes as well.
-
-
In NetSuite, go to Commerce > Websites> Configuration.
-
In the Advanced tab and Custom Fields subtab, add your transaction body field ID to the Sales Order property. See Custom Fields Subtab for more information about this configuration property.
Note:If any transaction body fields where available in the Vinson release of SCA or earlier, you must expose them in the configuration as well.
To display the custom transaction body field:
-
You can add a custom transaction body field to any module template linked to a checkout wizard step or in the Purchase History pages of My Account. See Supported Field Types for a list of supported field types.
As part of your theme, update the appropriate template:
-
To render information in Checkout, override any applicable checkout wizard template.
-
To render the information in My Account, override the
order_history_details.tplor theorder_history_summary.tpl, as required.
See Develop Themes for details on creating themes.
Note:If you implementing a SuiteCommerce Advanced site using the Kilimanjaro release or earlier, you must override the appropriate template. See Develop Your SCA Customization for details.
-
-
In your template, you can include the custom field’s metadata as an option. This is important for rendering the label of a field, for example. The
label,type, andmandatorymetadata components apply to all supported transaction body field types. Theoptionsmetadata component applies to List/Record types only.Note:After changing the
type,label, ormandatoryattributes of a transaction body field, your site uses the metadata values for up two hours. If you configure a new transaction body field, and that field’s attribute is not in the cache, the cache reloads, attempting to get the requested metadata. If the Sales Order Field ID property does not belong to any transaction body field, the application does not render that field.To display metadata for the custom field, include the following helpers (where
custbody_my_transaction_body_fieldis the ID of your custom transaction body field):Note:The metadata is available in the Sales Order object as part of the
__customFieldsMetadataattribute. In your template override, access custom field metadata by introducing the following script (wherecustbody_my_transaction_body_fieldis the ID of your custom transaction body field).Metadata Fields
Information
Script
Label
Display the label of the field
model.__customFieldsMetadata.custbody_my_transaction_body_field.label Type
Display the type of the field
model.__customFieldsMetadata.custbody_my_transaction_body_field.type Mandatory
Display the Mandatory field. This is information only and is not validated in the frontend (client side).
model.__customFieldsMetadata.custbody_my_transaction_body_field.mandatory Options
Display the options for a List/Record field.
model.__customFieldsMetadata.custbody_my_transaction_body_field.options -
To display the value of a transaction body field, include the following helper (where
custbody_my_transaction_body_fieldis the ID of your custom transaction body field):{{model.options.custbody_my_transaction_body_field}} -
To request information from a user, include an
input,textarea, orselectcomponent (where thenameproperty is the custom field ID). Whenever the Change event is triggered on the field, the value of the HTML component is set in the model associated with the template.The following examples use the Label metadata to display the label of the custom TBF:
<div> {{model.__customFieldsMetadata.custbody_my_transaction_body_field.label}}: <input type="text" name="custbody_my_transaction_body_field" value="{{model.options.custbody_my_transaction_body_field}}"> </div><div> {{model.__customFieldsMetadata.custbody_my_transaction_body_field_sel.label}} <select name="custbody_my_transaction_body_field_sel"> {{#each model.__customFieldsMetadata.custbody_my_transaction_body_field_sel.options}} <option value="{{id}}" {{#ifEquals id ../model.options.custbody_my_transaction_body_field_sel}}selected="true"{{/ifEquals}}> {{text}} </option> {{/each}} </select> </div><div> {{model.__customFieldsMetadata.custbody_my_transaction_body_field_2.label}} <textarea name="custbody_my_transaction_body_field_2"> {{model.options.custbody_my_transaction_body_field_2}} </textarea> </div>
Supported Field Types
Commerce websites support custom transaction body fields of the following Type:
|
Type |
Example HTML5 Elements Used to Render the Field |
|---|---|
|
Check Box |
text, checkbox |
|
Currency |
text |
|
Date |
text, date |
|
Date/Time |
text, datetime |
|
Decimal Number |
text, number |
|
Document |
select |
|
Email Address |
text, email |
|
Free Form Text |
text |
|
Hyperlink |
url |
|
Inline HTML |
text |
|
Integer Number |
text, number |
|
List/Record |
input, select |
|
Long Text |
text |
|
Multiple Select |
select |
|
Password |
text, password |
|
Percent |
text |
|
Phone Number |
text, tel |
|
Rich Text |
text |
|
Text Area |
text, textarea |
|
Time of Day |
text, time |