The Salesforce Developers website will undergo maintenance on May 29, 2024 from 3:00 a.m. UTC to 10:00 a.m. UTC. The maintenance process may affect the availability of our documentation. Please plan accordingly.

Script Programming

Use B2C Commerce JavaScript to customize your ecommerce storefront application.

For details on specific B2C Commerce Script API, see the B2C Commerce API documentation.

  • Use B2C Commerce JavaScript to:

    • Add new calculations and logic to business processes
    • Create business objects (data)
    • Call web services
    • Integrate back-end systems
    • Process XML data
    • Share information across users
  • Use client-side processing to:

    • Validate user input (for example, checking values entered in forms)
    • Prompt users for confirmation and showing error or informational boxes
    • Conditionalize HTML
    • Perform other functions not requiring information from the server

B2C Commerce JavaScript is based on Rhino JavaScript. Multiple language versions are supported. The active compatibility mode determines the language version. Compatibility modes earlier than 21.2 use the ECMAScript 5 language version. Compatibility modes 21.2 or later enable the latest language version that includes some ECMAScript 6 constructs. See Compatibility Mode Changes for details.

B2C Commerce supports the following:

  • Mozilla extensions up to JavaScript 1.8
  • ECMAScript for XML (E4X)
  • Optional type specification support from JavaScript 2.0/ECMA 4th edition proposal and ActionScript, as in the following examples:
    • let a: String;
    • let p: dw.catalog.Product;
  • Nonstandard behavior for older compatibility modes.