Brink CommerceConfigurationGetting startedIntegrationsModelsPrice and Shipping RulesConceptShipping ruleCart ruleProduct Feed

Price and Shipping Rules in Brink Commerce

Concept

Brink Commerce have two different rules SHIPPING and CART. SHIPPING is used to provide the customer with correct shipping option based on cart data. CART is used to set different product variant prices based cart data.

There are provided templates to create rules. Based on the templates you can created rules for SHIPPING and CART.

To add new templates please contact support.

Shipping rule

Get shipping template rule

Swagger

curl --request GET \
--url 'https://api.${env}.brinkcommerce.com/orderv1/rules/templates?type=SHIPPING' \
--header 'x-api-key: ${api key}'

Response

[
{
"lastUpdated": "2020-10-18T16:06:01.667Z",
"created": "2020-10-18T16:06:01.667Z",
"jsonSchema": {
"description": "Add a shipping rule.",
"title": "Shipping Rule",
"type": "object",
"required": ["operator", "shippingOptions", "countryOptions"],
"properties": {
"countryOptions": {
"type": "array",
"title": "Country options",
"items": {
"type": "object",
"required": ["totalPriceWithDiscount"],
"properties": {
"totalPriceWithDiscount": {
"type": "integer",
"title": "The price to be compared to"
},
"notForShippingCountry": {
"type": "array",
"title": "Don't include these countries",
"items": {
"type": "string",
"pattern": "[A-Z]{2}"
}
},
"currencyUnit": {
"type": "string",
"title": "The currency unit to map against",
"pattern": "[A-Z]{3}"
},
"shippingCountry": {
"type": "string",
"title": "The shipping country to map against",
"pattern": "[A-Z]{2}"
}
}
}
},
"operator": {
"type": "string",
"title": "Comparison operator for the rule",
"pattern": "^(==|>|>=|<|<=)$"
},
"shippingOptions": {
"type": "array",
"title": "Shipping option ids",
"items": {
"type": "string",
"pattern": "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"
}
}
}
},
"handlebarTemplate": "{\"id\":\"{{id}}\",\"ruleType\":\"SHIPPING\",\"ruleData\":{},\"action\":{\"type\":\"ADD_SHIPPING_OPTIONS\",\"values\":[{{#each shippingOptions}}\"{{this}}\"{{#unless @last}},{{/unless}}{{/each}}]},\"logicRule\":{\"or\":[{{#each countryOptions}}{\"and\":[{\"{{{../operator}}}\":[{\"var\":\"totalPriceWithDiscount\"},{{totalPriceWithDiscount}}]}{{#if currencyUnit}},{\"===\":[{\"var\":\"store.currencyUnit\"},\"{{currencyUnit}}\"]}{{/if}}{{#if shippingCountry}},{\"===\":[{\"var\":\"shippingCountry\"},\"{{shippingCountry}}\"]}{{/if}}{{#if notForShippingCountry.length}},{\"!\":[{\"in\":[{\"var\":\"shippingCountry\"},[{{#each notForShippingCountry}}\"{{this}}\"{{#unless @last}},{{/unless}}{{/each}}]]}]}{{/if}}]}{{#unless @last}},{{/unless}}{{/each}}]}}",
"id": "caff7180-1c92-4eb4-88f8-5941ec71e508",
"name": "Shipping Rule Advanced",
"type": "SHIPPING"
}
]

The response contains a JSON schema to be used to validate the templateData when you add a rule.

Add shipping rule

Swagger

curl --request POST \
--url https://api.${env}.brinkcommerce.com/orderv1/rules \
--header 'content-type: application/json' \
--header 'x-api-key: ${api key}' \
--data '{
"templateData": {
"operator": ">=",
"shippingOptions": [
"e805999e-9378-4511-bfd9-7770ea1788d0"
],
"countryOptions": [
{
"totalPriceWithDiscount": 20000,
"currencyUnit": "SEK",
"shippingCountry": "SE"
}
]
},
"name": "UPS express",
"active": true,
"templateId": "caff7180-1c92-4eb4-88f8-5941ec71e508"
}'

Response

{
"id": "39d7f86d-3414-4f0f-923e-077aa44427f3",
"name": "UPS express",
"templateId": "caff7180-1c92-4eb4-88f8-5941ec71e508",
"brinkRule": "{\"id\":\"39d7f86d-3414-4f0f-923e-077aa44427f3\",\"ruleType\":\"SHIPPING\",\"ruleData\":{},\"action\":{\"type\":\"ADD_SHIPPING_OPTIONS\",\"values\":[\"e805999e-9378-4511-bfd9-7770ea1788d0\"]},\"logicRule\":{\"or\":[{\"and\":[{\">=\":[{\"var\":\"totalPriceWithDiscount\"},20000]},{\"===\":[{\"var\":\"store.currencyUnit\"},\"SEK\"]},{\"===\":[{\"var\":\"shippingCountry\"},\"SE\"]}]}]}}",
"templateData": "{\"operator\":\">=\",\"shippingOptions\":[\"e805999e-9378-4511-bfd9-7770ea1788d0\"],\"countryOptions\":[{\"totalPriceWithDiscount\":20000,\"currencyUnit\":\"SEK\",\"shippingCountry\":\"SE\"}]}",
"active": 1,
"type": "SHIPPING",
"created": "2020-10-28T13:39:46.026Z",
"lastUpdated": "2020-10-28T13:39:46.026Z"
}

Cart rule

Get cart template rule

Swagger

curl --request GET \
--url 'https://api.${env}.brinkcommerce.com/orderv1/rules/templates?type=CART' \
--header 'x-api-key: ${api key}'

Response

[
{
"lastUpdated": "2020-10-26T18:08:04.671Z",
"created": "2020-10-26T18:08:04.671Z",
"jsonSchema": {
"description": "Add a cart rule.",
"title": "Cart Rule",
"type": "object",
"required": ["discountInPercentage", "currencyOptions"],
"properties": {
"currencyOptions": {
"type": "array",
"title": "Currency options",
"items": {
"type": "object",
"required": ["atLeastTotalPriceWithDiscount", "currencyUnit"],
"properties": {
"atLeastTotalPriceWithDiscount": {
"type": "integer",
"title": "Price with discount should be at least",
"minimum": 0
},
"currencyUnit": {
"type": "string",
"title": "The currency unit to map against",
"pattern": "[A-Z]{3}"
},
"atMostTotalPriceWithDiscount": {
"type": "integer",
"title": "Price with discount should be at least",
"minimum": 0
}
}
}
},
"discountInPercentage": {
"exclusiveMaximum": 100,
"type": "integer",
"title": "The discount in percentage, 0 - 99",
"minimum": 0
}
}
},
"handlebarTemplate": "{\"id\":\"{{id}}\",\"ruleType\":\"CART\",\"ruleData\":{},\"action\":{\"value\":{{discountInPercentage}},\"type\":\"ADD_CARTDISCOUNT_PERCENTAGE\"},\"logicRule\":{\"or\":[{{#each currencyOptions}}{\"and\":[{\">=\":[{\"var\":\"totalPriceWithDiscount\"},{{atLeastTotalPriceWithDiscount}}]}{{#if atMostTotalPriceWithDiscount}},{\"<\":[{\"var\":\"totalPriceWithDiscount\"},{{atMostTotalPriceWithDiscount}}]}{{/if}},{\"===\":[{\"var\":\"store.currencyUnit\"},\"{{currencyUnit}}\"]}]}{{#unless @last}},{{/unless}}{{/each}}]}}",
"id": "dd48c5a4-e81d-40a8-9cd0-c6a61bc140a9",
"name": "Cart Rule, discount on cart within range",
"type": "CART"
}
]

Add cart rule

Swagger

curl --request POST \
--url https://api.${env}.brinkcommerce.com/orderv1/rules \
--header 'content-type: application/json' \
--header 'x-api-key: ${api key}' \
--data '{
"templateData": {
"discountInPercentage": 10,
"currencyOptions": [
{
"atLeastTotalPriceWithDiscount": 50000,
"atMostTotalPriceWithDiscount": 70000,
"currencyUnit": "SEK"
}
]
},
"name": "Cart discount 10%",
"active": true,
"templateId": "dd48c5a4-e81d-40a8-9cd0-c6a61bc140a9"
}'

Response

{
"id": "cb5b7ae1-54da-4b60-a733-9232d060a05d",
"name": "Cart discount 10%",
"templateId": "dd48c5a4-e81d-40a8-9cd0-c6a61bc140a9",
"brinkRule": "{\"id\":\"cb5b7ae1-54da-4b60-a733-9232d060a05d\",\"ruleType\":\"CART\",\"ruleData\":{},\"action\":{\"value\":10,\"type\":\"ADD_CARTDISCOUNT_PERCENTAGE\"},\"logicRule\":{\"or\":[{\"and\":[{\">=\":[{\"var\":\"totalPriceWithDiscount\"},50000]},{\"<\":[{\"var\":\"totalPriceWithDiscount\"},70000]},{\"===\":[{\"var\":\"store.currencyUnit\"},\"SEK\"]}]}]}}",
"templateData": "{\"discountInPercentage\":10,\"currencyOptions\":[{\"atLeastTotalPriceWithDiscount\":50000,\"atMostTotalPriceWithDiscount\":70000,\"currencyUnit\":\"SEK\"}]}",
"active": 1,
"type": "CART",
"created": "2020-10-28T13:54:33.749Z",
"lastUpdated": "2020-10-28T13:54:33.749Z"
}