> For the complete documentation index, see [llms.txt](https://docs.horizon.ipaper.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.horizon.ipaper.io/horizon-api/methods-and-events/offer-legacy-campaigns.md).

# Offer (legacy campaigns)

### `getOffer`

Get a specific offer by providing an offer `guid`.  Return an `ILeafletOffer`

```javascript
const offer = api.offer.getOffer(offerGuid);
console.log('Offer', offer);
```

`ILeafletOffer`

| Property     | Type                | Description          |
| ------------ | ------------------- | -------------------- |
| $type        | `'offer'`           | content type         |
| offerGuid    | `string`            | guid of offer        |
| header       | `string`            | header of offer      |
| summary      | `string`            | summary of offer     |
| sales\_price | `{ value: number }` | sales price of offer |
| products     | `ILeafletProduct[]` | products on offer    |

`ILeafletProduct`

| Property    | Type                | Description           |
| ----------- | ------------------- | --------------------- |
| $type       | `'product'`         | content type          |
| sku         | `string`            | sku of product        |
| title       | `string`            | title of product      |
| url         | `string`            | url of product        |
| price       | `{ value: number }` | price of product      |
| sale\_price | `{ value: number }` | sale price of product |
| brand       | `string`            | product brand         |

### `getOffers`

Get all offers in the experience. Returns an array of `ILeafletOffer`.

```javascript
const offers = api.offer.getOffers();
console.log('Offers', offers);
```

`ILeafletOffer`

| Property     | Type                | Description          |
| ------------ | ------------------- | -------------------- |
| $type        | `'offer'`           | content type         |
| offerGuid    | `string`            | guid of offer        |
| header       | `string`            | header of offer      |
| summary      | `string`            | summary of offer     |
| sales\_price | `{ value: number }` | sales price of offer |
| products     | `ILeafletProduct[]` | products on offer    |

`ILeafletProduct`

| Property    | Type                | Description           |
| ----------- | ------------------- | --------------------- |
| $type       | `'product'`         | content type          |
| sku         | `string`            | sku of product        |
| title       | `string`            | title of product      |
| url         | `string`            | url of product        |
| price       | `{ value: number }` | price of product      |
| sale\_price | `{ value: number }` | sale price of product |
| brand       | `string`            | product brand         |

### `getOfferElement`

Get a specific offer element by providing an offer `guid`. Returns an `HTMLElement`.

```javascript
const element = api.offer.getOfferElement(offerGuid);
console.log('Element', element);
```

### `getOffersInView`

Get all offers currently in view. Returns an `ILeafletOffer`.

```javascript
const inView = api.offer.getOffersInView();
console.log('In view', inView);
```

`ILeafletOffer`

| Property     | Type                | Description          |
| ------------ | ------------------- | -------------------- |
| $type        | `'offer'`           | content type         |
| offerGuid    | `string`            | guid of offer        |
| header       | `string`            | header of offer      |
| summary      | `string`            | summary of offer     |
| sales\_price | `{ value: number }` | sales price of offer |
| products     | `ILeafletProduct[]` | products on offer    |

`ILeafletProduct`

| Property    | Type                | Description           |
| ----------- | ------------------- | --------------------- |
| $type       | `'product'`         | content type          |
| sku         | `string`            | sku of product        |
| title       | `string`            | title of product      |
| url         | `string`            | url of product        |
| price       | `{ value: number }` | price of product      |
| sale\_price | `{ value: number }` | sale price of product |
| brand       | `string`            | product brand         |

***

## Subscription events

The following events can be subscribed to in order to execute code when they occur. The code that should be executed is passed as a callback function when subscribing. You can set up multiple subscriptions to the same event.

These can be very useful f.ex. for tracking with Google Analytics, etc.

### `subscribe`

Subscribe to offers entering the viewport.

```javascript
api.offer.subscribe((offerEvent) => {
    // your code
});
```

`offerEvent`

|        |                                                 |                                       |
| ------ | ----------------------------------------------- | ------------------------------------- |
| action | `'viewEnter'` \| `'viewLeave'` \| `'click'`     | name of the event action that occured |
| source | `'offer'` \| `'price'` \| `'splash'` \| `'cta'` | source of the event                   |
| value  | `ILeafletOffer`                                 | the offer the event occured for       |

`ILeafletOffer`

| Property     | Type                | Description          |
| ------------ | ------------------- | -------------------- |
| $type        | `'offer'`           | content type         |
| offerGuid    | `string`            | guid of offer        |
| header       | `string`            | header of offer      |
| summary      | `string`            | summary of offer     |
| sales\_price | `{ value: number }` | sales price of offer |
| products     | `ILeafletProduct[]` | products on offer    |

`ILeafletProduct`

| Property    | Type                | Description           |
| ----------- | ------------------- | --------------------- |
| $type       | `'product'`         | content type          |
| sku         | `string`            | sku of product        |
| title       | `string`            | title of product      |
| url         | `string`            | url of product        |
| price       | `{ value: number }` | price of product      |
| sale\_price | `{ value: number }` | sale price of product |
| brand       | `string`            | product brand         |

### `unsubscribe`

In addition, when you set up a subscription you will get an `unsubscribe` function returned which can be used to cancel the subscription at any time. For example:

```javascript
let myClickSubscription = api.offer.subscribe((offerEvent) => {
    // your code
});

myClickSubscription.unsubscribe();
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.horizon.ipaper.io/horizon-api/methods-and-events/offer-legacy-campaigns.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
