Mircate
  1. Promotion
Mircate
  • Introduction
  • Authentication
  • Errors
  • Change Logs
  • PIM
    • Get Products
      POST
    • Get Product Settings
      GET
    • Get Catalog Settings
      GET
    • Upsert Product
      POST
    • Upsert Category
      POST
    • Bulk Product Upsert
      POST
    • Check Batch Status
      POST
    • Delete Product
      POST
    • Attach Product Attribute Image
      POST
    • Attach Category Image
      POST
    • Get Image
      GET
    • Upsert Attributes
      POST
    • Delete Attribute
      POST
    • Upsert Attribute Options
      POST
    • Upsert Attribute Option
      POST
    • Delete Attribute Option
      POST
  • Promotion
    • Calculate
      POST
    • Start Transaction
      POST
    • Commit Transaction
      POST
    • Revert Transaction
      POST
    • Cancel Transaction
      POST
    • Get Active Promotions
      GET
  • Loyalty
    • Receive Event
      POST
    • Calculate
      POST
    • Start Transaction
      POST
    • Commit Transaction
      POST
    • Cancel Transaction
      POST
    • List Measurements
      POST
  • Wallet
    • Get Wallet
    • Create Wallet
    • Create Account
    • Get Account
    • Get Accounts
    • List Accounts
    • List Transactions
    • Add Account
    • Remove Account
    • Fix
    • Load
    • Spend
    • Refund
    • Cancel
  • Talking Product
    • Create Product
    • Update Product
    • Delete Product
    • Get Product
    • List Product
  • Merchant
    • Sales Channel
      • Reserve Stock
      • Cancel Stock
      • Commit Stock
      • Refund Stock
      • Get Current Stock
    • Product Supplier
      • Receive Stock
      • Receive Price
      • Get Stock/Price History
      • Check Batch Status
      • Remove My Products
      • Clean My Products
      • Export Stock/Price
      • List Exports
      • Get Exported Files
    • Global Products
      • Receive Products
      • Get Global Products
      • Remove Global Products
  • Common
    • Dataset
      • Create
      • Update
      • Delete
      • Value Upsert
      • Value Delete
      • List Sources
      • List Values
  • How to
    • Creating a Promotion Template
    • Promotion Transaction Flow
    • Understanding PIM Product Statuses
  1. Promotion

Calculate

Production
https://api.b2b.retter.io/5p1hp1d2t
Production
https://api.b2b.retter.io/5p1hp1d2t
POST
https://api.b2b.retter.io/5p1hp1d2t
/CALL/Promotion/calculate/{PROJECT_ID}
Promotion
Last modified:2024-11-26 14:32:38
This API endpoint allows you to calculate promotions based on the cart information of an order. The calculate method calculates and returns the promotions that are applicable to the given order's cart.
The API responds with a list of promotions that are applicable to the given cart.
Data Structure for Customers Using Both Loyalty and Promotions
The data structure for customers using both loyalty and promotions should be formatted as follows:
Note: The values for object arrays such as subOrders, condiments, items, etc., should not contain nested objects. In other words, there should be no second-level objects within these arrays. Data in array format should only consist of primitive types like string[], number[], etc.
{
  // Object arrays (like subOrders, items, condiments, etc.) should be single-level.
  "subOrders": [
    {
      "subOrderId": "1",
      "id": "33047",
      "price": 108,
      // Extra product attributes should be sent directly in the subOrder, without adding another level, such as "attributes".
      "brand": "Ulker",
      "name": "Ulker Napoliten Milk Chocolate",
      "categories": [
          "snacks",
          "chocolate"
      ]
    },
    {
      "subOrderId": "2",
      "id": "43047",
      "price": 110,
      // Extra attributes can be sent directly within the subOrder like this.
      "brand": "Starbucks",
      "name": "Starbucks Cafe Latte",
      "categories": [
          "drinks",
          "coffee"
      ]
    }
  ],
  "condiments": [
    {
      "subOrderId": "2",
      "id": "10002",
      "name": "Caramel",
      "price": 12,
      "type": "condiment"
    }
  ]
}

Request

Authorization
Add parameter in header
x-api-key
Example:
x-api-key: ********************
Path Params
PROJECT_ID
string 
required
Header Params
x-api-key
string 
optional
{{B2B_PROMOTION_API_KEY}}
Example:
{{PROMOTION_END_USER_API_KEY}}
Body Params application/json
runWithLoyalty
boolean 
deprecated
The runWithLoyalty parameter has been deprecated. Loyalty calculations are now automatically processed when the Loyalty module is active, removing the need for this additional parameter.
usePoint
number 
optional
Calculate the maximum points to be distributed in the shopping cart.
pointCurrency
string 
optional
storeId
string 
optional
storeName
string 
optional
cart
object 
required
items
array [object {7}] 
optional
If you wish, you can send additional fields to have them used in promotional calculations.
subOrders
array [object {5}] 
required
If you wish, you can send additional fields to have them used in promotional calculations.
productCount
integer 
optional
couponId
string 
optional
user
object 
required
orders
array [object] 
optional
userId
string 
required
Example
{
    "cart": {
        "items": [
            {
                "merchantId": "string",
                "id": "string",
                "qty": 0,
                "attributes": {
                    "shortName": "string",
                    "longName": "string",
                    "brand": "string",
                    "categories": [
                        {
                            "id": "string",
                            "name": "string"
                        }
                    ],
                    "images": [
                        "string"
                    ],
                    "productLimit": 0,
                    "logisticTags": [],
                    "etiketler": [
                        "string"
                    ]
                },
                "price": 0,
                "totalPrice": 0,
                "itemType": "string"
            }
        ],
        "subOrders": [
            {
                "merchantId": "string",
                "subOrderId": "string",
                "id": "string",
                "price": 0,
                "itemType": "string"
            }
        ],
        "productCount": 0
    },
    "couponId": "string",
    "user": {
        "userId": "string"
    }
}

Request samples

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.b2b.retter.io/5p1hp1d2t/CALL/Promotion/calculate/' \
--header 'Content-Type: application/json' \
--header 'x-api-key;' \
--data-raw '{
    "cart": {
        "items": [
            {
                "merchantId": "string",
                "id": "string",
                "qty": 0,
                "attributes": {
                    "shortName": "string",
                    "longName": "string",
                    "brand": "string",
                    "categories": [
                        {
                            "id": "string",
                            "name": "string"
                        }
                    ],
                    "images": [
                        "string"
                    ],
                    "productLimit": 0,
                    "logisticTags": [],
                    "etiketler": [
                        "string"
                    ]
                },
                "price": 0,
                "totalPrice": 0,
                "itemType": "string"
            }
        ],
        "subOrders": [
            {
                "merchantId": "string",
                "subOrderId": "string",
                "id": "string",
                "price": 0,
                "itemType": "string"
            }
        ],
        "productCount": 0
    },
    "couponId": "string",
    "user": {
        "userId": "string"
    }
}'

Responses

🟢200OK
application/json
Successful response
Body
cart
object 
optional
items
array [object {13}] 
optional
subOrders
array [object {15}] 
optional
productCount
integer 
optional
appliedPromotions
array [object {6}] 
optional
suggestionPromotions
array [object {4}] 
optional
totalCartPriceAfterPromotion
integer 
optional
totalCartPromotionDiscount
integer 
optional
userBalance
number 
optional
totalPriceAfterPointUsed
number 
optional
totalUsablePoints
number 
optional
totalUsablePointAsMoney
number 
optional
totalUsedPoints
number 
optional
totalUsedPointAsMoney
number 
optional
totalPriceToPay
number 
optional
calculationTime
integer 
optional
Example
{
    "cart": {
        "items": [
            {
                "merchantId": "string",
                "id": "string",
                "qty": 0,
                "attributes": {
                    "shortName": "string",
                    "longName": "string",
                    "brand": "string",
                    "categories": [
                        {
                            "id": "string",
                            "name": "string"
                        }
                    ],
                    "images": [
                        "string"
                    ],
                    "productLimit": 0,
                    "logisticTags": [
                        {}
                    ],
                    "etiketler": [
                        "string"
                    ]
                },
                "price": 0,
                "totalPrice": 0,
                "itemType": "string",
                "promotionDiscount": 0,
                "priceAfterPromotion": 0,
                "appliedPromotions": [
                    {
                        "id": "string",
                        "promotionTemplateId": "string",
                        "giftAmount": 0
                    }
                ],
                "totalPromotionDiscount": 0,
                "totalPriceAfterPromotion": 0,
                "totalDisplayPrice": 0
            }
        ],
        "subOrders": [
            {
                "merchantId": "string",
                "subOrderId": "string",
                "id": "string",
                "price": 0,
                "itemType": "string",
                "priceAfterPromotion": 0,
                "displayPrice": 0,
                "promotionDiscount": 0,
                "appliedPromotions": [
                    {
                        "id": "string",
                        "promotionTemplateId": "string",
                        "giftAmount": 0
                    }
                ],
                "usedPoints": 0,
                "usedPointAsMoney": 0,
                "priceAfterPointUsed": 0,
                "usablePoints": 0,
                "usablePointAsMoney": 0,
                "pointMultiplier": 0
            }
        ],
        "productCount": 0,
        "appliedPromotions": [
            {
                "id": "string",
                "promotionTemplateId": "string",
                "giftAmount": 0,
                "tag": "string",
                "promotionType": "string",
                "userMessage": "string"
            }
        ],
        "suggestionPromotions": [
            {
                "id": "string",
                "userMessage": "string",
                "suggestion": "string",
                "additionalData": {}
            }
        ],
        "totalCartPriceAfterPromotion": 0,
        "totalCartPromotionDiscount": 0,
        "userBalance": 0,
        "totalPriceAfterPointUsed": 0,
        "totalUsablePoints": 0,
        "totalUsablePointAsMoney": 0,
        "totalUsedPoints": 0,
        "totalUsedPointAsMoney": 0,
        "totalPriceToPay": 0
    },
    "calculationTime": 0
}
🟠400Bad Request
🟠403Forbidden
🟠404Record Not Found
Modified at 2024-11-26 14:32:38
Previous
Delete Attribute Option
Next
Start Transaction
Built with