# Campaigns

## Campaigns

Campaigns describe temporary prices used at one or more stores *for a specific time period*. Campaigns are usually used to show customers the original price and how much they save during the campaign. For this reason, campaigns are layered on top of the stores pricelist when used by Shoppa.

Like pricelists, campaigns are described in a StoreInformation `package`. Campaigns are always created with a start- and a stopdate and they always need a name that can be used in Shoppa Client to select it.

*As with pricelists, campaigns can be identified with* `name`*,* `startDate` *and* `countryCode`*, but for simplicity we recommend using a reliable* `id` *instead.*

A campaign can not be converted to a pricelist and vice versa. If you create the wrong kind of package you need to delete the package and create a new one from scratch.

## A basic campaign

Lets make a 50% off campaign for our sample glass `65467-14` from October 1st - 4th. The xml for this is:

```markup
<storeInformation customerID="S123" customerIDType="ExternalID" createDate="2008-09-10T09:32:50" schemaVersion="1.6" xmlns="http://shoppa.com/storeInfoSchema">
    <package id="99001" name="Glass weekend" startDate="2008-10-01" stopDate="2008-10-04" countryCode="se">
        <product id="65467-14" idType="Code1">
            <field name="price" value="102.50" />
        </product>
    </package>
</storeInformation>
```

## Changing the duration

We decide to postpone our campaign one day and extend it to a full week. If we simply set a new startDate we would update product prices at that date rather than of changing the startdate of the entire campaign. Moving the campaign thus requires us to use the attribute `newStartDate`:

```markup
<storeInformation customerID="S123" customerIDType="ExternalID" createDate="2008-09-10T10:14:20" schemaVersion="1.6" xmlns="http://shoppa.com/storeInfoSchema">
    <package id="99001" name="Glass week!" newStartDate="2008-10-02" stopDate="2008-10-08" countryCode="se" />
</storeInformation>
```

## Campaign visibility

What campaigns to run in an organization may be known a long time at HQ, but it may be sensitive to tell the stores too early and risk informing customers and competitors. By setting the `visibleStartDate` attribute you decide how long beforehand the stores see the campaign. All users at HQ still see the campaign in their clients and can validate its content.

Similarly, some stores may want access to campaigns after they formally end, to run them a little longer and get rid of excess stock. To keep the campaign visible in Shoppa Client after the campaign ends you set the `visibleStopDate` attribute.

```markup
<storeInformation customerID="S123" customerIDType="ExternalID" createDate="2008-09-10T09:32:50" schemaVersion="1.6" xmlns="http://shoppa.com/storeInfoSchema">
    <package id="99001" name="Glass week!" startDate="2008-10-02" stopDate="2008-10-08" visibleStartDate="2008-10-01" visibleStopDate="2008-10-15" countryCode="se">
        <product id="65467-14" idType="Code1">
            <field name="price" value="102.50" />
        </product>
    </package>
</storeInformation>
```

## Complement products

A product can have complement products assigned to it specifically in a campaign. You can also assign campaign information to the complement products as you are assigning them. Note that values cannot be set with the `value` attribute, they have to be contained by the `field` element.

You should also add the attribute `complementBehaviour` to the product element. This takes one of three values and determines the way complement products are added and/or removed. The accepted values are `replace`, `delete` and `merge`. They do the following:

* **Replace:** Removes all existing complement products and replaces them with the new ones. This is the default option.
* **Delete:** Removes all existing complement products. Any new complement products will be ignored.
* **Merge:** Adds the new complement products to the set of existing ones.

```markup
<storeInformation customerID="S123" customerIDType="ExternalID" createDate="2008-09-10T09:32:50" schemaVersion="1.6" xmlns="http://shoppa.com/storeInfoSchema">
    <package id="99001" name="Glass weekend" startDate="2008-10-01" stopDate="2008-10-04" countryCode="se">
        <product id="65467-14" idType="Code1" complementBehaviour="merge">
            <field name="price" value="102.50" />
            <complementProduct id="33648-03" idType="Code1" />
            <complementProduct id="33648-04" idType="Code1">
                <field name="text1">Batteries not included</field>
                <field name="price">24.90</field>
            </complementProduct>
        </product>
    </package>
</storeInformation>
```

## Deleting a campaign

If a campaign should be removed completely, that can be achieved by setting the `delete` attribute in the `package` tag. We refer to the campaign by defining the corresponding `id`, `startDate`, and `stopDate`. The xml for this is simply:

```xml
<storeInformation customerID="S123" customerIDType="ExternalID" createDate="2008-09-10T09:32:50" schemaVersion="1.6" xmlns="http://shoppa.com/storeInfoSchema">
    <package id="99001" name="Glass week!" delete="true" startDate="2008-10-02" stopDate="2008-10-08" countryCode="se" />
</storeInformation>
```

## Removing a product from the campaign

If we instead only want to remove a selection of products from the campaign, we set the `delete` attribute in the `product` tag. The xml for this is simply:

```xml
<storeInformation customerID="S123" customerIDType="ExternalID" createDate="2008-09-10T09:32:50" schemaVersion="1.6" xmlns="http://shoppa.com/storeInfoSchema">
    <package id="99001" name="Glass week!" startDate="2008-10-02" stopDate="2008-10-08" visibleStartDate="2008-10-01" visibleStopDate="2008-10-15" countryCode="se">
        <product id="65467-14" idType="Code1" delete="true" />
    </package>
</storeInformation>
```


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://shoppa.gitbook.io/knowledge-hub/api-documentation/xml-structure/campaigns.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
