API Campaigns

This document explains prices, discounts and campaigns in general and the use of the Extend Commerce API endpoint CustomerOrderCampaignProcessor

Prices and campaigns

Prequisities

Order has a customer. It might be needed to setup an anonymous customer if the customer is not known.
Customer is connected to one or more price lists/discount lists.
Products are connected to price list/discount list.

Prices and campaing calculations

The process is executed in following order.

  1. Get price for an order row
    • If price is specified that price will be used. This is prefered.
    • If no price is specified Extend Commerce will use the minimum price from the price list/discount lists available for the customer
    • If no price is specified and a PromotionCode is set, Extend Commerce will try to find minimum price from discount list using the specified PromotionCode. A discount list with promotion code does not need to be connected to the customer.
  2. Expand any bill of materials product. If the product is bill of materials, its child products will be added as new order rows referring to their parent using the property billOfMaterialsParentRowPosition. For API preview/campaign validation, the price of the bill of materials will be kept on parent. The added child rows will get price=0.
  3. Campains are applied if the campaigns are connected to the Customer. Campaigns can have an additional condition of needing a PromotionCode. Order rows added by a campaign will have output isResultOfPromotion=true and promotionName=’Name of promotion in use’. A campaign can result in an added order row with negative price, eg “10% discount when total amount is greater than 100”
  4. “Product auto order” (eg buy two get one for free) is applied for all customers. Order rows added by “Product auto order” will have output isResultOfPromotion=true and promotionName=null. Additional info is placed in CustomerOrderRow.product.productNotes = ‘Auto ordered, triggered by product {TriggerProductName}’
  5. Campaigns for freight discounts are applied last.

Performance

For performance reason it is best to include prices (unitPrice, vatPercent, currency) when you know them:

"salesData": {
        "quantity": 1,
        "unit": "FRP",
        "unitPrice": 12,
        "vatPercent": 0,
        "currency": "DKK"
      }

Promotion code

Promotion code is used both for discount lists and campaigns.

A discount list connected to a customer group will always be available for that customer group regardless of promotion code.

A discount list with a promotion code should not be connected to any customer group.

A discount list with a promotion code will be available for all customers as long as a correct promotion code is specified.


A campaign with promotion code is available if a correct promotion code is specified and the customer is connected to a customer group having the campaign.

Place order

When placing an order using Extend Commerce API (endpoint CustomerOrders) the following is expected:

  • All order rows that are added by campaigns using the campaign processor (endpoint CustomerOrderCampaignProcessor) must be included in POST request. These order rows should if possible be marked with the used promotionName to prevent limited campaigns to be used multiple times.
  • Expanded bill of material children order rows (having property billOfMaterialsParentRowPosition set in response from campaign processor) must not be included in POST request.


The endpoint CustomerOrderATP will ignore campaigns and product auto order. CustomerOrderATP is supposed to handle delivery information, ie balance and dates.


Both CustomerOrders POST and CustomerOrderATP have the possibility to process campaigns if promotion property is set on customerOrderHeader:
"Promotion": {"usePromotions": "true","PromotionCode": "MegaSale2020"}

Examples

Bill of materials

Bill of materials request



Bill of materials response

Notes for bill of materials response:

Rows having property billOfMaterialsParentRowPosition set in response from campaign processor must not be included in CustomerOrders POST request when placing the order.


Product auto order

Auto order request:




Auto order response:

Notes for auto order

Rows having property isResultOfPromotion set in response from campaign processor must be included in CustomerOrders POST request when placing the order.

Campaign 50% off with promotion code

Campaign 50% off request:

Campaign 50% off response:

Notes for Campaign request and response

Request:

Response:

Rows having property isResultOfPromotion set in response from campaign processor must be included in CustomerOrders POST request when placing the order.