Capturing a customer's IP address can help in monitoring Checkout traffic and also possible fraudulent transactions.
Using the code <%=getCurrentAttribute('request','ipaddress')%> allows the capture of the IP address of the customer. It can be saved in the customer record using a Custom Transaction Body field.
1. Create a Transaction Body Field:
a. Navigate to Set up > Customization > Transaction Body Field > New.
b. Name the field as IP Address.
c. Optional: Set _ip_address as it's internal ID (Note: You can leave this blank and let the system auto-generate the field's internal ID which can be similar to custbody##)
d. Set Type to Free text.
e. Set Store Value to True.
f. At the Applies to tab, mark Webstore which will automatically mark Sale.
g. At the Display tab, change the Display type to Inline Text.
h. Click Save.
2. Set the Custom Script to the Checkout tab
a. Navigate to Lists > Website > Tabs > Checkout.
b. Look for the Place Order Page Message field.
c. Click on the link that says HTML Source Code right next to Formatted Text.
Note: If this link is not available, Rich Text Editing needs to be enabled at Home > Set Preferences > General tab.
d. Place the following sample code:
Note : In this example the ID of the body field is custbody_ip_address . If user left the Internal ID blank before saving, replace the 'custbody_ip_address' with the system-generated Internal ID.
e. Save the Tab.
Custom Script Used:
This code hides the transaction body field so that the customers will not see the transaction body field at the Review and Submit page:
This code assigns that IP address of the customer to the transaction body field that was created: