ShoppingSession Methods
The shoppingSession object tracks session context and can call the following methods:
-
getAbsoluteUrl(domaintype,path) (Deprecated)
-
getPasswordHint(customerEmail) (Deprecated)
-
getSiteCategoryContents(siteCategory, recursive) (Deprecated)
-
isLoggedIn() (Deprecated)
-
sendPasswordRetrievalEmail(customeremail) (Deprecated)
If the method includes item as a parameter, enter the internal ID as a string, not an integer.
constructDomainBridgingUrl(link)
Converts cross-domain link to domain bridging URL containing encrypted parameters. This method provides a secure way to transfer shopper data between different domains.
Do not change or extract data from the domain bridging URL as the format of the URL may change. Only use the URL in the browser to retrieve and apply the shopper session data from the original domain.
Parameters
-
link
[required] {String} – Absolute or relative URL of link targeting a different shopping or checkout domain from the one the shopper is currently on
Returns
-
link
{String} – Domain bridging URL; the original URL is returned if bridging is either not possible or not necessary -
null
– Returned if the input parameter is invalid
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
doChangePassword(Params, newPassword)
Changes the password for the customer identified by email. Returns true if the password is changed correctly.
Throws the following errors:
-
ERR_WS_INVALID_LINK – if parameters contain a token that is expired or incomplete. Note that it is not possible to determine if the link is expired or incomplete. The same error is thrown in either case.
-
ERR_WS_INVALID_PASSWORD – if the password is empty or exceeds the maximum allowed length of 255 characters.
-
ERR_WS_WEAK_PASSWORD – if the password at least 6 characters.
Parameters
-
Params
– pass parameters from original request -
newPassword
– {String} value for new password to be set
Returns
Boolean
Supported Domains
Checkout
Login Required?
no
Back to ShoppingSession Methods | Back to Shopping Objects
getAbsoluteUrl(domaintype,path)
In certain scenarios, the getAbsoluteUrl(domaintype,path)
method returns a relative URL instead of an absolute URL. For example, the getAbsoluteUrl(domaintype,path)
method returns a relative URL when the target domain is same as the current domain.
Therefore, the getAbsoluteUrl(domaintype,path)
method has been removed as of NetSuite Release 2017.1. Use the getAbsoluteUrl2(domaintype,path)
method instead.
Gets absolute URL for given path and domain type.
Parameters
-
domaintype
[optional] {String} - value should be either “shopping” or “checkout” -
path
[required] {String}
Returns
String
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getAbsoluteUrl2(domaintype,path)
Gets absolute URL for given path and domain type.
This method should be used instead of the previous getAbsoluteUrl(domaintype,path)
method.
Parameters
-
domaintype
[optional] {String} - value should be either “shopping” or “checkout” -
path
[required] {String}
Returns
String
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getAllCustomerSegmentTypes()
Gets all customer segment types available in the account, that is, all defined customer groups as well as the default groups of All Users, Anonymous Users, and Recognized and Logged In Users.
Parameters
No parameters to set.
Returns
Array of objects with fields:
-
id
{string} -
name
{string}
Supported Domains
All
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getAllCustomerSegments()
Gets all customer segments that are in use in the Customer Segment Manager. For more information, see Managing which Customer Segments can Access Item Segments.
Parameters
No parameters to set.
Returns
Array of objects with fields:
-
id
{number} -
name
{string} -
customerSegmentType
{string}
Supported Domains
All
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getCampaignID()
Gets the campaign ID of the leadsource parameter from the current session.
Parameters
No parameters to set.
Returns
campaignid
{String}
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getCorrelatedItems(item)
Gets array of correlated items for given item.
Complete details are returned for a correlated item only if the item is:
-
available in the store from which the API was called
-
available in personalized catalog view for the customer (if Personalized Catalog Views is enabled -for more information, see Personalized Catalog Views)
Parameters
-
item
[required]{object with values for fields}-
internalid
[required] -
itemtype
[required] -
itemfields
[optional] {array of item field names to query}
-
For better performance limit the number of queried fields by specifying only fields you need in the itemfields array.
Returns
Array of objects of type item
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getCountries()
Gets all countries
Parameters
No parameters to set.
Returns
Array of objects with fields:
-
name
{string} -
code
{string} -
isziprequired
{boolean}
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getCustomer()
Gets the Customer details from the current session.
Parameters
No parameters to set.
Returns
Returns the customer shopping object. For more information, see Customer Methods.
The customer object holds information within the given shopping session only and is different from the NetSuite customer record.
Supported Domains
Checkout, Shopping
Login Required?
Yes
Back to ShoppingSession Methods | Back to Shopping Objects
getCountryTaxPreferences()
Returns a JSON object with tax preferences related a shopper’s country. The values returned are based on the default shopper subsidiary derived from the site or the country selected by the shopper.
Parameters
No parameters to set.
Returns
-
vatregistration
{boolean} — When set to T, the VAT registration field can be displayed during checkout and thevatregistration
can be set on the customer object.
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getEffectiveShoppingDomain()
Returns name of shopping domain associated with current session.
Parameters
No parameters to set.
Returns
domainname
{String} – The shopping domain related to the current session. For example: shopping.corp.netsuite.com
.
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getInformationItemFieldValues(infoItems)
Gets attribute values for given information items.
Parameters
-
infoItems
[required] {Array}
Each object in array has values for field:
-
internalid
[required]
Returns
Array of objects of type item.
Depending on item fields configured, the array of objects returned might differ.
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getItemFieldValues(items)
Gets attribute values for given items.
Complete details are returned for an item only if the item is:
-
available in the store from which the API was called
-
available in personalized catalog view for the customer (if Personalized Catalog Views is enabled -for more information, see Personalized Catalog Views)
Parameters
-
items
[required] {Array} Each object in array has values for fields:-
internalid
[required] -
itemtype
[required]
-
Returns
Array of objects of type item.
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getPartnerID()
Gets the Partner ID of the leadsource parameter from the current session.
Parameters
No parameters to set.
Returns
partnerid
{String}
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getPasswordHint(customerEmail)
Retrieves password hint for customer with given email address.
Password hints are no longer necessary. The password retrieval email message includes a URL with a password reset code. Therefore, the getPasswordHint() method has been removed as of NetSuite Release 2017.2. As of 2017.2, the method will return an empty string, but generate no errors.
Parameters
-
customerEmail
[required] {String}
Returns
An empty string
Supported Domains
Checkout
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getPaymentMethod(paymentMethodId, fields)
Gets payment method for given ID.
Parameters
-
paymentMethodId
[required] {String} -
fields
[optional] Array of field names to be included in returned JSON object; if omitted, all supported fields are returned
Returns
Object of type paymentmethod.
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getPaymentMethods(fields)
Gets payment methods accepted by the web store.
Parameters
-
fields
[optional] Array of field names to be included in returned JSON object; if omitted, all supported fields are returned
Returns
Array of objects of type paymentmethod.
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getRedirectURL()
Gets the URL which is the result of a redirect given the input. Returns null if there is no redirect. Wildcards are also supported (*).
Parameters
-
url
[required] {String}
Returns
String
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getRelatedItems(item)
Gets array of related items for given item.
Complete details are returned for a related item only if the item is:
-
available in the store from which the API was called
-
available in personalized catalog view for the customer (if Personalized Catalog Views is enabled -for more information, see Personalized Catalog Views)
Parameters
-
item
[required]{object with values for fields}-
internalid
[required] -
itemtype
[required] -
itemfields
[optional] {array of item field names to query}
-
For better performance limit the number of queried fields by specifying only fields you need in the itemfields array.
Returns
Array of objects of type item.
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getRelatedCorrelatedItems()
Gets a list of related or correlated items, or both, for a given item ID.
Complete details are returned for a related item only if the item is:
-
available in the store from which the API was called
-
available in personalized catalog view for the customer (if Personalized Catalog Views is enabled -for more information, see Personalized Catalog Views)
Parameters
-
type
: [required]{string} Available options are RELATED, CORRELATED, or BOTH. -
fieldsetid
: set of fields returned. -
items
: list of item IDs. When not specified, items from the cart are returned. -
limit
: Maximum count of returned items. When not specified, the default 10 is used. -1 sets no limit.Important:Use caution when setting the limit to -1 as this can have an impact on performance.
Example
function service(request, response)
{
var session = nlapiGetWebContainer().getShoppingSession();
items = ['101'];
response.writeLine("Related Items: " + JSON.stringify(session.getRelatedCorrelatedItem'RELATED', 'relateditems', items, 10)));
response.writeLine("Correlated Items: " + JSON.stringify(session.getRelatedCorrelatedItems('CORRELATED', 'relateditems', items, 10)));
response.writeLine("Related & Correlated Items: " + JSON.stringify(session.getRelatedCorrelatedItems('BOTH', 'relateditems', items, 10)));
}
Returns
Array of correlated or related items.
Supported Domains
Checkout, Shopping
Login Required?
No
Back to Order Methods | Back to Shopping Objects
getShipToCountries()
Gets countries to which web store can ship.
Parameters
No parameters to set.
Returns
Array of objects with fields:
-
name{string}
-
code{string}
-
isziprequired
{boolean}
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getShopperCurrency()
Gets currency for current shopping session.
Parameters
No parameters to set.
Returns
Object with values for fields:
-
internalid
{String} -
name
{String} -
symbol
{String} -
precision
{Number}
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getShopperLanguageLocale()
Gets language and locale for current shopping session.
Parameters
No parameters to set.
Returns
localeid
{String}
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getShopperPreferences()
Gets language, subsidiary, and currency preferences for the current shopping session.
Parameters
No parameters to set.
Returns
Object with values for fields:
-
language
{String} -
subsidiary{String}
-
currency{String}
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getShopperSubsidiary()
Gets subsidiary for current shopping session.
Parameters
No parameters to set.
Returns
subsidiaryid
{String}
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getSiteCategoryContents(siteCategory, recursive)
The getSiteCategoryContents()
API has been removed as of NetSuite Release 2014.2. Use the getSiteCategoryTree()
method instead. See getSiteCategoryTree(siteCategory).
Gets contents of given site category.
If not provided, siteCategory
will be defaulted to the root category, and recursive will be defaulted to false. When recursive is set to false
, the API returns the category contents that include subcategories and items; when recursive is set to true
, the API returns the complete tree of subcategories but not items.
To get the complete category tree from the root, use getSiteCategoryContents(true)
.
Parameters
-
siteCategory
[optional] {Array} Each object in array has values for field:internalid
[required] -
recursive
[optional]
Returns
Array of objects of type sitecategory or item.
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getSiteCategoryFieldValues(siteCategories)
Gets attribute values of given site categories.
Parameters
-
siteCategories
[required] {Array} Each object in array has values for field:internalid
[required]
Returns
Array of objects of type sitecategory.
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getSiteCategoryTree(siteCategory)
When the internalid
attribute is present in the siteCategory
object, then the method returns the category sub-tree from this category. When the internalid
attribute is not specified, then the whole category tree of the specified site is returned.
When calling this API, you must specify which fields to return. When no fields are specified, then no fields are returned except the internalids
of categories. Specify fields using the itemfields
attribute on the siteCategory
object.
Examples
-
The following example returns the entire category tree for the current site. Each category record contains the fields
internalid
,pagetitle2
, andurlcomponent
.getSiteCategoryTree({ itemfields : ["pagetitle2","urlcomponent"] });
-
The following example returns the category sub-tree of category 65. Each category record contains only the
internalid
field.getSiteCategoryTree({ id : 65 });
The examples above return only the category tree, not the category contents.
Parameters
-
siteCategory
[optional] {Array} Each object in array has values for field:internalid
[required]
Returns
Array of objects of type sitecategory
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getSiteSettings(fields)
Gets settings of current web store.
Parameters
-
fields
[optional] Array of field names to be included in returned JSON object; if omitted, all supported fields are returned
Returns
Object with fields listed for sitesettings JSON object.
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getSSPApplication()
Gets URL root of SSP application powering the current touchpoint.
Parameters
No parameters to set.
Returns
urlroot
field value for sitesettings JSON object.
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
getStates(countries)
Gets states and provinces.
Parameters
-
countries
[optional] Array of strings for country codes
Returns
Returns an array of state/province names and state/province codes in the following format:
{"states":[{"name":"Alabama","code":"AL"},{"name":"Alaska","code":"AK"},...], "countrycode":"US"}
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
isChangePasswordRequest()
Returns true if all page parameters from the current request are valid for the password reset.
Throws the error "ERR_WS_INVALID_LINK" if all page parameters from the current request contain required parameters for password reset but the link has expired or is incomplete.
Parameters
No parameters to set.
Returns
Boolean
Supported Domains
Checkout
Login Required?
no
Back to ShoppingSession Methods | Back to Shopping Objects
isLoggedIn()
Checks whether the customer has logged in. This method can be used with the isRecognized()
method. See Using isRecognized() with isLoggedIn3().
This method is no longer supported. For new Commerce implementations, use the isLoggedIn3() method. The isLoggedIn() method works correctly in the Checkout domain but may not work when used in the Shopping domain even when the user is logged in. If you encounter session issues when using this API, contact support for assistance to migrate to the isLoggedIn3()
method.
Parameters
No parameters to set.
Returns
Boolean
Supported Domains
Checkout
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
isLoggedIn2()
Checks whether the customer has logged in. This method can be used with the isRecognized()
method. See Using isRecognized() with isLoggedIn3().
This method is no longer supported. For new Commerce implementations, use the isLoggedIn3() method. The isLoggedIn2()
method works correctly in the Checkout domain but may not work correctly when used with elevated permissions. If you encounter session issues when using this API, contact support for assistance to migrate to the isLoggedIn3()
method.
Parameters
No parameters to set.
Returns
Boolean
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
isLoggedIn3()
Checks whether the customer has logged in. This method can be used with the isRecognized()
method. See Using isRecognized() with isLoggedIn3().
This method should be used instead of the previous isLoggedIn()
method and the isLoggedIn2()
method.
Parameters
No parameters to set.
Returns
Boolean
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
isRecognized()
Determines whether a user is recognized. This method can be used with the isLoggedIn2()
and isLoggedIn3()
methods. However, isLoggedIn3()
is the preferred method. See Using isRecognized() with isLoggedIn3().
Parameters
No parameters to set.
Returns
Boolean
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
logIn(customer)
Logs in a customer.
Parameters
-
customer
[required]{object with values for fields}-
email
[required] -
password
[required]
-
Returns
Object with fields:
-
customerid
{String} -internal id of customer record for logged in customer -
redirecturl{String}
-URL to which user is redirected after logging in
Supported Domains
Checkout
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
logout()
Logs out a customer.
If logout()
is attempted from a shopping context, it does not succeed and an error is returned.
Parameters
No parameters to set.
Returns
Object with field:
-
redirecturl
The field redirecturl
has the complete home URL to redirect to after logout. If not using the redirecturl
field returned from logout(), the custom redirecturl should have the logoff=T
parameter.
Supported Domains
Checkout
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
proceedToCheckout(checkoutSettings)
Used for integration with a third party checkout provider such as PayPal Express. This API can only be called from a secure scheme (https).
Parameters
-
checkoutSettings
Object with values for fields:-
type;
either “paypalexpress” or “google” -
continueurl
-
cancelurl
-
Returns
No value returned.
Supported Domains
Checkout
Must have at least one order.
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
registerCustomer(customer)
Registers the customer and logs them in.
Parameters
-
customer
[required]{object with values for fields}-
firstname
[required] {String} -
lastname
[required] {String} -
companyname
[optional] {String} -
email
[required] {String} -
password
[required] {String} -
password2
[required] {String} -
passwordhint
[optional] {String} -
emailsubscribe
[optional] {String} -
leadsource
[optional] {String}
-
Returns
Object with values for fields:
-
customerid
{String} -internal id of record for registered customer -
redirecturl
{String} -URL to which user is redirected after registering
Supported Domains
Checkout
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
registerGuest(guest)
Registers a guest.
Throws exception if register guest with password.
Parameters
-
guest
[optional]{object with values for fields}-
firstname
[optional] {String} -
lastname
[required] {String}
-
Returns
Object with values for fields:
-
customerid
{String} -internal id of record for registered customer -
redirecturl
{String} -URL to which user is redirected after registering
Supported Domains
Checkout
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
sendPasswordRetrievalEmail(customeremail)
Sends password retrieval email message to the given email address.
The password reset link generated by the sendPasswordRetrievalEmail() includes the customer’s email address. Therefore the method has been removed as of NetSuite Release 2017.2. Use the sendPasswordRetrievalEmail2(customeremail) method instead.
Parameters
-
customerEmail
[required] {String}
Returns
No value returned.
Supported Domains
Checkout
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
sendPasswordRetrievalEmail2(customeremail)
Sends password retrieval email message to the given email address.
This method does not include the customer’s email address in the reset password link. Use this method instead of the previous method, sendPasswordRetrievalEmail(customeremail).
Parameters
-
customerEmail
[required] {String}
Returns
No value returned.
Supported Domains
Checkout
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
setShopperCurrency(currencyid)
Sets currency for current shopping session
Multiple Currencies feature must be enabled, specified currency must be supported in sitesettings, and logged in user must have permission to change currency.
Parameters
-
currencyid
[required] {string}
Returns
No value returned.
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
setShopperLanguageLocale(localeid)
Sets language and locale for current shopping session
Multi-Language feature must be enabled, and specified language must be supported in sitesettings.
Parameters
-
localeid
[required]{String}
Returns
No value returned.
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
setShopperPreferences(prefs)
Sets language, subsidiary and currency for current shopping session.
Parameters
-
prefs
[required]{object with values for fields}-
language
[optional] {String} -
subsidiary
[optional] {String} -
currency
[optional] {String}
-
Returns
No value returned.
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
setShopperSubsidiary(subsidiary)
Sets subsidiary for current shopping session (for NetSuite OneWorld users).
The subsidiary set in a session is not currently supported out-of-the-box for One World in the SuiteCommerce Advanced SuiteApp. For the SuiteCommerce Advanced SuiteApp, further customization is necessary. Also, the subsidiary for an existing recognized customer can not be changed using this API.
Parameters
-
subsidiary
[required]{String}
Returns
No value returned.
Supported Domains
Checkout, Shopping
Login Required?
No
Back to ShoppingSession Methods | Back to Shopping Objects
verifyEmailChange(key)
Takes an email change key, verifies it, and then changes the email. If the request can't be processed, an exception is thrown.
Parameters
-
key
[required]{String} — value of the email change key.
Returns
Boolean
Returns true
if the key value is valid and the email has been changed. Returns false
in all other cases (for example, if the key is invalid or expired).
Supported Domains
Checkout
Login Required?
Yes
Back to ShoppingSession Methods | Back to Shopping Objects
Using isRecognized() with isLoggedIn3()
There are four possible scenarios for using the isLoggedIn3()
method with the isRecognized()
method to correctly determine if a user is logged in:
-
New (anonymous) user:
isRecognized() ==false
andisLoggedIn3() ==false
-
Registered and logged-in user:
isRecognized() ==true
andisLoggedIn3() ==true
-
User clicked the logout link:
isRecognized() ==false
andisLoggedIn3() ==false
-
User logged in, then closed the browser and later returned to your Commerce store:
isRecognized() ==true
andisLoggedIn3() ==false
The fourth scenario is the only case where the isRecognized()
status differs from the isLoggedIn3()
status. In this case, the user did not click on the logout link and is therefore still recognized but is not logged in.