ShoppingSession Methods

The shoppingSession object tracks session context and can call the following methods:

Note:

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.

Note:

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
Returns
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:

Parameters
Returns

Boolean

Supported Domains

Checkout

Login Required?

no

Back to ShoppingSession Methods | Back to Shopping Objects

getAbsoluteUrl(domaintype,path)

Important:

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
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.

Note:

This method should be used instead of the previous getAbsoluteUrl(domaintype,path) method.

Parameters
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:

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:

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.

Note:

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
Note:

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:

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.

Note:

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
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

Each object in array has values for field:

Returns

Array of objects of type item.

Note:

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.

Note:

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
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.

Important:

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
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
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
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
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.

Note:

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
Note:

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.

Note:

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

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:

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:

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:

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)

Important:

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.

Note:

To get the complete category tree from the root, use getSiteCategoryContents(true).

Parameters
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
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

Note:

The examples above return only the category tree, not the category contents.

Parameters
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
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
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().

Important:

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().

Important:

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().

Important:

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
Returns

Object with fields:

Supported Domains

Checkout

Login Required?

No

Back to ShoppingSession Methods | Back to Shopping Objects

logout()

Logs out a customer.

Note:

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:

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
Returns

No value returned.

Supported Domains

Checkout

Note:

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
Returns

Object with values for fields:

Supported Domains

Checkout

Login Required?

No

Back to ShoppingSession Methods | Back to Shopping Objects

registerGuest(guest)

Registers a guest.

Note:

Throws exception if register guest with password.

Parameters
Returns

Object with values for fields:

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.

Important:

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
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.

Note:

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
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

Note:

Multiple Currencies feature must be enabled, specified currency must be supported in sitesettings, and logged in user must have permission to change currency.

Parameters
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

Note:

Multi-Language feature must be enabled, and specified language must be supported in sitesettings.

Parameters
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
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).

Important:

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
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
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:

  1. New (anonymous) user: isRecognized() == false and isLoggedIn3() == false

  2. Registered and logged-in user: isRecognized() == true and isLoggedIn3() == true

  3. User clicked the logout link: isRecognized() == false and isLoggedIn3() == false

  4. User logged in, then closed the browser and later returned to your Commerce store: isRecognized() == true and isLoggedIn3() == false

Note:

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.

Related Topics:

General Notices