# Order Event

Use order events to capture customer interactions with ecommerce orders in your mobile application, such as purchases, cancellations, returns, and order status changes. These events help you understand customer purchasing behavior and order management patterns.

## Event Structure

All order events require an `order` with these fields:

| Field Name | Field Type                                                                                                              | Required | Description                     |
| ---------- | ----------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------------- |
| `order`    | [Order Attribute](/docs/data/data-cloud-engagement-mobile-sdk/guide/c360a-api-engagement-mobile-sdk-order-attribute.md) | Yes      | A single order attribute value. |

## Event Types

The Order Event supports these interaction types:

- Purchase: Track when customers complete a purchase
- Preorder: Capture when customers place preorders
- Cancel: Track when customers cancel orders
- Ship: Monitor when orders are shipped
- Deliver: Track when orders are delivered
- Return: Capture when customers return orders
- Exchange: Track when customers exchange orders

## Purchase Order Event

Track when customers complete a purchase.

```sfdocs-code {"lang":"swift", "title": "iOS Example", "src": "" }
PurchaseOrderEvent(
    order: Order(
        id: "order-1",
        totalValue: 9.99,
        currency: "USD",
        attributes: [
            "PROMO_CODE": "HELLO"
        ],
        lineItems: [
            LineItem(
                catalogObjectType: "Product",
                catalogObjectId: "product-11",
                quantity: 1,
                price: 20,
                currency: "USD",
                attributes: [
                    "gift_wrap": true
                ]
            )
        ]
    )
)
```

```sfdocs-code {"lang":"kotlin", "title": "Android Example", "src": "" }
OrderEvent.purchase(
    order = Order(
        id = "order-1",
        totalValue = 9.99,
        currency = "USD",
        attributes = mapOf(
            "PROMO_CODE" to "HELLO"
        ),
        lineItems = listOf(
            LineItem(
                catalogObjectId = "product-1",
                catalogObjectType = "Product",
                quantity = 1,
                price = 20.0,
                currency = "USD",
                attributes = mapOf(
                    "gift_wrap" to true
                )
            )
        )
    )
)
```

## Preorder Order Event

Capture when customers place preorders.

```sfdocs-code {"lang":"swift", "title": "iOS Example", "src": "" }
PreOrderEvent(
    order: Order(
        id: "order-1",
        totalValue: 9.99,
        currency: "USD",
        attributes: [
            "PROMO_CODE": "HELLO"
        ],
        lineItems: [
            LineItem(
                catalogObjectType: "Product",
                catalogObjectId: "product-11",
                quantity: 1,
                price: 20,
                currency: "USD",
                attributes: [
                    "gift_wrap": true
                ]
            )
        ]
    )
)
```

```sfdocs-code {"lang":"kotlin", "title": "Android Example", "src": "" }
OrderEvent.preorder(
    order = Order(
        id = "order-1",
        totalValue = 9.99,
        currency = "USD",
        attributes = mapOf(
            "PROMO_CODE" to "HELLO"
        ),
        lineItems = listOf(
            LineItem(
                catalogObjectId = "product-1",
                catalogObjectType = "Product",
                quantity = 1,
                price = 20.0,
                currency = "USD",
                attributes = mapOf(
                    "gift_wrap" to true
                )
            )
        )
    )
)
```

## Cancel Order Event

Track when customers cancel orders.

```sfdocs-code {"lang":"swift", "title": "iOS Example", "src": "" }
CancelOrderEvent(
    order: Order(
        id: "order-1",
        totalValue: 9.99,
        currency: "USD",
        attributes: [
            "PROMO_CODE": "HELLO"
        ],
        lineItems: [
            LineItem(
                catalogObjectType: "Product",
                catalogObjectId: "product-11",
                quantity: 1,
                price: 20,
                currency: "USD",
                attributes: [
                    "gift_wrap": true
                ]
            )
        ]
    )
)
```

```sfdocs-code {"lang":"kotlin", "title": "Android Example", "src": "" }
OrderEvent.cancel(
    order = Order(
        id = "order-1",
        totalValue = 9.99,
        currency = "USD",
        attributes = mapOf(
            "PROMO_CODE" to "HELLO"
        ),
        lineItems = listOf(
            LineItem(
                catalogObjectId = "product-1",
                catalogObjectType = "Product",
                quantity = 1,
                price = 20.0,
                currency = "USD",
                attributes = mapOf(
                    "gift_wrap" to true
                )
            )
        )
    )
)
```

## Ship Order Event

Monitor when orders are shipped.

```sfdocs-code {"lang":"swift", "title": "iOS Example", "src": "" }
ShipOrderEvent(
    order: Order(
        id: "order-1",
        totalValue: 9.99,
        currency: "USD",
        attributes: [
            "PROMO_CODE": "HELLO"
        ],
        lineItems: [
            LineItem(
                catalogObjectType: "Product",
                catalogObjectId: "product-11",
                quantity: 1,
                price: 20,
                currency: "USD",
                attributes: [
                    "gift_wrap": true
                ]
            )
        ]
    )
)
```

```sfdocs-code {"lang":"kotlin", "title": "Android Example", "src": "" }
OrderEvent.ship(
    order = Order(
        id = "order-1",
        totalValue = 9.99,
        currency = "USD",
        attributes = mapOf(
            "PROMO_CODE" to "HELLO"
        ),
        lineItems = listOf(
            LineItem(
                catalogObjectId = "product-1",
                catalogObjectType = "Product",
                quantity = 1,
                price = 20.0,
                currency = "USD",
                attributes = mapOf(
                    "gift_wrap" to true
                )
            )
        )
    )
)
```

## Deliver Order Event

Track when orders are delivered.

```sfdocs-code {"lang":"swift", "title": "iOS Example", "src": "" }
DeliverOrderEvent(
    order: Order(
        id: "order-1",
        totalValue: 9.99,
        currency: "USD",
        attributes: [
            "PROMO_CODE": "HELLO"
        ],
        lineItems: [
            LineItem(
                catalogObjectType: "Product",
                catalogObjectId: "product-11",
                quantity: 1,
                price: 20,
                currency: "USD",
                attributes: [
                    "gift_wrap": true
                ]
            )
        ]
    )
)
```

```sfdocs-code {"lang":"kotlin", "title": "Android Example", "src": "" }
OrderEvent.deliver(
    order = Order(
        id = "order-1",
        totalValue = 9.99,
        currency = "USD",
        attributes = mapOf(
            "PROMO_CODE" to "HELLO"
        ),
        lineItems = listOf(
            LineItem(
                catalogObjectId = "product-1",
                catalogObjectType = "Product",
                quantity = 1,
                price = 20.0,
                currency = "USD",
                attributes = mapOf(
                    "gift_wrap" to true
                )
            )
        )
    )
)
```

## Return Order Event

Capture when customers return orders.

```sfdocs-code {"lang":"swift", "title": "iOS Example", "src": "" }
ReturnOrderEvent(
    order: Order(
        id: "order-1",
        totalValue: 9.99,
        currency: "USD",
        attributes: [
            "PROMO_CODE": "HELLO"
        ],
        lineItems: [
            LineItem(
                catalogObjectType: "Product",
                catalogObjectId: "product-11",
                quantity: 1,
                price: 20,
                currency: "USD",
                attributes: [
                    "gift_wrap": true
                ]
            )
        ]
    )
)
```

```sfdocs-code {"lang":"kotlin", "title": "Android Example", "src": "" }
OrderEvent.returnOrder(
    order = Order(
        id = "order-1",
        totalValue = 9.99,
        currency = "USD",
        attributes = mapOf(
            "PROMO_CODE" to "HELLO"
        ),
        lineItems = listOf(
            LineItem(
                catalogObjectId = "product-1",
                catalogObjectType = "Product",
                quantity = 1,
                price = 20.0,
                currency = "USD",
                attributes = mapOf(
                    "gift_wrap" to true
                )
            )
        )
    )
)
```

## Exchange Order Event

Track when customers exchange orders.

```sfdocs-code {"lang":"swift", "title": "iOS Example", "src": "" }
ExchangeOrderEvent(
    order: Order(
        id: "order-1",
        totalValue: 9.99,
        currency: "USD",
        attributes: [
            "PROMO_CODE": "HELLO"
        ],
        lineItems: [
            LineItem(
                catalogObjectType: "Product",
                catalogObjectId: "product-11",
                quantity: 1,
                price: 20,
                currency: "USD",
                attributes: [
                    "gift_wrap": true
                ]
            )
        ]
    )
)
```

```sfdocs-code {"lang":"kotlin", "title": "Android Example", "src": "" }
OrderEvent.exchange(
    order = Order(
        id = "order-1",
        totalValue = 9.99,
        currency = "USD",
        attributes = mapOf(
            "PROMO_CODE" to "HELLO"
        ),
        lineItems = listOf(
            LineItem(
                catalogObjectId = "product-1",
                catalogObjectType = "Product",
                quantity = 1,
                price = 20.0,
                currency = "USD",
                attributes = mapOf(
                    "gift_wrap" to true
                )
            )
        )
    )
)
```
