Scriptable Cart Fundamentals and Set Up

If you are not familiar with Scriptable Cart, read the following sections to learn more about when and how to implement its capabilities for SuiteCommerce or SuiteCommerce Advanced (SCA) websites.

What is Scriptable Cart?

With Scriptable Cart, SuiteCommerce developers can use SuiteScript to invoke client scripts on the sales order form used for website orders.

Note:

SuiteScript is not available for use in web store registration. You can use an SSP application to customize a website registration page. For more information, see SSP Application Overview.

At its most basic, Scriptable Cart is a single SuiteScript file that you deploy to your NetSuite instance that executes when a sales order is created on the Commerce website or in the backend UI.

Scriptable Cart works by listening to events in the client and then performing actions when those events are triggered. Generally speaking, events are grouped as follows:

Event Group

Description

Example

pageInit

After the user logs into the Commerce website

fieldChanged

After a field is modified by the customer or by a script

Address line modification

postSourcing

After a field that sources information from another field or list is modified (similar to fieldChanged, except only called after all sourcing is finished)

Dependent/cascaded field changes

validateLine

Before an item is added to or changed in the cart

User tries to increase the quantity of an item, but is prevented because of an artificial limit set by a script

recalc

After shopping cart contents are changed

An item is added or removed or a quantity is changed

saveRecord

After the sales order submit form call is made, but before it is saved

Note:

You do not need to use these specific event names in the scripts you create; rather these names are used in the backend to refer to these events. But, it is best practice to use some form of these names to help you and others on your team easily maintain your scripts. For example, if your script executes some code after the shopper attempts to add an item to the cart, you could call it validateLineOnItemAdd or customValidateLine.

The events listed in the preceding table are the basis of the client and user event functions supported by Scriptable Cart. You can implement these functions in your scripts to customize the checkout flow. For more information about these functions, see Basic Custom Functions.

Why Implement a Scriptable Cart?

Use Scriptable Cart when the customization you need cannot be accomplished by developing an extension or by customizing SuiteCommerce or SCA. For example, you may:

  • Want to run your customization code in both the Commerce website and the UI

  • Need to modify an item rate

The preceding examples can only be implemented using Scriptable Cart.

Where Can Scriptable Cart Run?

The script you write can run during checkout on a SuiteCommerce or SCA website. However, you can also write the script so that it runs when a staff member places an order on behalf of a customer in the NetSuite UI. Typically, however, you choose to execute the script in only one of these places.

Note:

To learn more about using Scriptable Cart with Site Builder websites, see Scriptable Cart.

Keep the following in mind when deciding whether to implement Scriptable Cart:

  • A NetSuite UI script runs with permissions of an administrator, whereas a Scriptable Cart runs with either customer center or shopper access.

  • You cannot trigger alerts in Scriptable Cart.

  • With Scriptable Cart, functions are called much more frequently, which can negatively impact performance.

How Does Scriptable Cart Communicate with SuiteCommerce and SCA?

It is not uncommon to want to send information to a Scriptable Cart from SuiteCommerce or SCA so that you can trigger some function to run. To do this, you can use a custom transaction body or column field to set the information you need in SuiteCommerce or SCA, and then call that field in the Scriptable Cart.

Set Up Scriptable Cart

To set up Scriptable Cart, an administrator needs to enable the features described in the following steps.

Note:

SuiteScript 2.1 client scripts are not currently supported in Scriptable Cart. For more information about SuiteScript 2.1, see SuiteScript 2.1.

To set up Scriptable Cart:

  1. In NetSuite, go to Setup > Company > Enable Features.

  2. On the Enable Features page:

    1. Select the Web Presence tab and check the Advanced Site Customization box to enable the feature.

    2. Select the SuiteCloud tab and check the Client SuiteScript box to enable the feature.

  3. In NetSuite, go to Commerce > Websites > Website List.

  4. Click Edit next to your website.

  5. Go to the Setup tab.

  6. In the Preferences section, check the Scriptable Cart and Checkout box to enable the feature.

Related Topics

Start Using Scriptable Cart with SuiteCommerce or SCA
Basic Custom Functions
Best Practices for Using Scriptable Cart with SuiteCommerce or SCA
Scriptable Cart Gift Card Example for SuiteCommerce or SCA
Debugging Scriptable Cart for SuiteCommerce or SCA

General Notices