Skip to main content

Add Promotion Tutorial

How to add discount tutorial

This guide shows how to obtaining the promotions availability for the items added to the shopping cart and apply them easily.

Let's get started with the examples

Step-by-step examples

This guide shows how to obtaining and apply an discount step by step.

Prerequisites!

You will need a valid OAuth access_token to be able to make each call! Please refer to our Authentication Guide to obtain one.

Get Available Promotions and Discounts

This call returns the list of available promotions and discounts for the products in the shopping cart:

  • token Shopping cart identifier.
curl --location --request GET 'http://gateway-pre.oneboxtickets.net/onebox-rest2/rest/shoppingCart/availablePromotionsAndDiscounts?token={{cart-token}}' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{access_token}}' \
--header 'Content-Type: application/json'

Note: This endpoint returns a list of items that contains the information related to it's availability of promotions and discounts, so in order to be able to do the next step, we must take the item-id ("@id": "134145530" in the example below) and the desired promotion-id ( "@id": "19870" in the example below), you can see the list in more detail in this example:

EXAMPLE RESPONSE:

{
"@id": "134145530",
"promotions": {
"promotion": [
{
"@id": "19870",
"promotionComElements": {
"name": "Promotion - 10€"
},
"type": "FIXED",
"value": "10.0",
"mandatory": "false",
"self-managed": "false",
"limitedUses": "false"
}
]
},
}

Apply Promotion

Finally to apply the promotion we make this call to the addPromotion endpoint passing it an XML structure that includes the promotion-id, also send the item-id obtained in the previous step, and the cart-token of the shopping cart to which the discount is going to be applied:

  • promotion-id Discount unique identifier.
  • cart-token Shopping cart identifier token.
  • item-id Item unique identifier.
curl --location --request POST 'http://gateway-pre.oneboxtickets.net/onebox-rest2/rest/shoppingCart/addPromotion' \
--header 'Authorization: Bearer {{access_token}}' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Accept: application/json' \
--data-urlencode 'items=134145530' \
--data-urlencode 'promotion=<?xml version="1.0" encoding="UTF-8" standalone="yes"?><ns24:promotion id="19870" xmlns:ns2="http://www.oneboxtm.es/ns/channel" xmlns:ns4="http://www.oneboxtm.es/ns/communication" xmlns:ns3="http://www.oneboxtm.es/ns/languages" xmlns:ns6="http://www.oneboxtm.es/ns/profile" xmlns:ns31="http://www.oneboxtm.es/ns/rss-evento" xmlns:ns5="http://www.oneboxtm.es/ns/passbook" xmlns:ns30="http://www.oneboxtm.es/ns/sales/data" xmlns:ns8="http://www.oneboxtm.es/ns/amount" xmlns:ns7="http://binding.onebox.es/rest" xmlns:ns13="http://www.oneboxtm.es/ns/data-query/event" xmlns:ns9="http://www.oneboxtm.es/ns/availability" xmlns:ns12="http://www.oneboxtm.es/ns/attributes" xmlns:ns34="http://www.oneboxtm.es/ns/rest" xmlns:ns11="http://www.oneboxtm.es/ns/location" xmlns:ns33="http://www.oneboxtm.es/user" xmlns:ns10="http://www.oneboxtm.es/ns/customer" xmlns:ns32="http://search.yahoo.com/mrss/" xmlns:ns17="http://www.oneboxtm.es/ns/data-query/session" xmlns:ns16="http://www.oneboxtm.es/ns/commissions" xmlns:ns15="http://www.oneboxtm.es/ns/data-query/prices" xmlns:ns14="http://www.oneboxtm.es/ns/dates" xmlns:ns19="http://www.oneboxtm.es/ns/sales" xmlns:ns18="http://www.oneboxtm.es/ns/data-query/venue" xmlns:ns20="http://www.oneboxtm.es/ns/data-query/masterdata" xmlns:ns24="http://www.oneboxtm.es/ns/input-data/shopping/cart" xmlns:ns23="http://www.oneboxtm.es/ns/purchase/order" xmlns:ns22="http://www.oneboxtm.es/ns/data-query/places" xmlns:ns21="http://www.oneboxtm.es/ns/taxonomy" xmlns:ns28="http://www.oneboxtm.es/ns/search" xmlns:ns27="http://www.oneboxtm.es/ns/zpl" xmlns:ns26="http://www.oneboxtm.es/ns/data-query/products" xmlns:ns25="http://www.oneboxtm.es/ns/input-data/purchase/order" xmlns:ns29="http://www.oneboxtm.es/ns/shopping/cart"/>' \
--data-urlencode 'token={{cart-token}}'

Note: Although the integration is JSON, the promotion XML structure that you send as parameter must be in this XML format since the API expects this structure and format when receive and processing the call.