---
schema_version: "1"
id: aee348a47e73226241c5d4a2c2b46cc0c8db8da705ce930ca364d6250cd2fbc6
title: isloop Element
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/commerce-cloud/b2c-commerce/guides/isml/b2c-isloop.md
canonical_url: https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/b2c-isloop.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: daa176d9065df93fd0f93fa97752af4bed3a61f75a59315af239f988ba229b2c
products:
  - Composable Storefront
  - Salesforce APIs
---
# isloop Element

Create loops for flow control.

## Syntax

```
<isloop
  (items = item_object ) | (iterator = iter_object) //required
  (alias = alias_name) | (var = var_name)
   status = status_name
   begin  = start_index
   end    = stop_index
   step   = increment_index
  ...
</isloop>
```

- (items = item_object ) | (iterator = iter_object)

  - : _Allowed data type:_ expression.

    You must include one of the following but not both:

    - items = item_object

      `item_object` is an expression that returns an object to iterate over. Attributes _iterator_ and _items_ can be used interchangeably.

    - iterator = iter_object

      `iter_object`is an expression that returns an object to iterate over. Attributes _iterator_ and _items_ can be used interchangeably.

    `items`is preferred.

- (alias = alias_name) | (var = var_name)

  - : Name of the variable referencing the object in the iterable collection referenced in the current iteration.

    You must include one of the following but not both:

    - alias = alias_name :

      `alias_name` is the name of a variable referencing the object in the iterable collection referenced in the current iteration.

    - var = var_name :

      `var_name` is the name of a variable referencing the object in the iterable collection referenced in the current iteration.

    `var` is preferred.

- status = status_name

  - : `status_name` is the variable name referencing the loop status object. The loop status is used to query information such as the counter or whether it's the first item.

    If status is specified, a loop status object is assigned to the given variable name. Below are the properties of the loop status object:

    | Attribute | Description                                                   |
    | --------- | ------------------------------------------------------------- |
    | count     | The number of iterations, starting with 1.                    |
    | index     | The current index into the set of items, while iterating.     |
    | first     | True, if this is the first item while iterating (count == 1). |
    | last      | True, if this is the last item while iterating.               |
    | odd       | True, if count is an odd value.                               |
    | even      | True, if count is an even value.                              |

- begin = start_index

  - : _Allowed data type:_ expression.

    `start_index` is an expression specifying a begin index for the loop. If the begin is greater than 0, the \<isloop> skips the first x items and starts looping at the begin index. If begin is smaller than 0, 0 is used as the begin value.

- end = stop_index

  - : _Allowed data type:_ expression.

    `stop_index`is an expression specifying an end index (inclusive). If end is smaller than begin, the `<isloop>` is skipped.

- step = increment_index

  - : _Allowed data type:_ expression.

    `increment_index` is an expression specifying the step used to increase the index. If step is smaller than one, one is used as the step value.

## Purpose

With `<isloop>` you can loop through the elements of a specified iterator. As an example, you can list data like categories, products, shipping, and payment methods. `<isloop>` statements can be nested in one another.

## Supporting Tags

- Use `<isbreak>` to unconditionally terminate a loop.
- Use `<isnext>` to jump forward in a loop

See [isbreak](https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/b2c-isbreak.md) and <[isnext](https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/b2c-isnext.md) for more information.

## Example

```
<isloop iterator = "${pdict.Basket.products}" alias = "product">
<isprint value = "${product.name}"> <BR>
</isloop>
```

**note:** The previous pdict.Basket is merely an example of using the Pipeline Dictionary as it relates to the Reference Application. It isn't the same as the Basket class in Salesforce B2C Commerce server-side JavaScript.
