JavaScript Expressions in ISML

To simplify coding, we recommend that you use B2C Commerce JavaScript expressions within ISML templates.

Examples

This example prints the product display name from the Pipeline Dictionary:

<isprint value="${pdict.Product.displayName}"/>

The product SKU is:

${pdict.Product.sku}

This example checks if there are any items or gift certificates in the cart (as entered by the customer):

<isif condition="${empty(pdict.CurrentForms.cart.items) && empty(pdict.CurrentForms.cart.giftcerts)}">
<!--- empty basket --->
<div id="infoBox">Your shopping cart is empty.</div>	
<iselse>

The Empty Operator

Empty has a particular significance when accessing an object, as follows:

Operator Purpose
empty()

Returns true if the object is empty. Empty is defined as:

  • null
  • undefined
  • a string with zero length
  • an array with no elements
  • a collection with no elements
Note: If the object is never declared, the JavaScript throws a ReferenceError so Empty(object) isn't true.
isEmpty() Returns true if the collection is empty.
isNotEmpty()

If the object is empty, propagates an assertion using the specified message.

Parameters:

  • arg - the object to check.
  • msg - the assertion message.