Add special price promotion
Last updated: 12-Nov-2020
Rate this article:
Overview
Use the AddSpecialPricePromotion method to create a promotion with a special price.
Request parameters
Parameters | Type | Required | Description |
---|---|---|---|
Promotion | Object | Required | Contains details of the promotion. |
PriceMatrix | Array of Objects | Required | Only for this type of promotion. It is generated by getPriceMatrix and used to set promotion special prices. |
Coupon | Object | Required | Type of coupon applied to the promotion. |
Request sample
<?php
require('PATH_TO_AUTH');
$promotionObject = new stdClass;
$promotionObject->Name = 'YOUR_PROMOTION_TITLE';
$promotionObject->Description = 'YOUR_PROMOTION_DESCRIPTION';
$promotionObject->DefaultCurrency = "EUR";
$promotionObject->StartDate = date('Y-m-d', strtotime('1 month ago'));
$promotionObject->EndDate = date('Y-m-d', strtotime('+1 month'));
$promotionObject->Type = 'SPECIAL_PRICE';
$promotionObject->Enabled = 1;
$promotionObject->MaximumOrdersNumber = 0;
$promotionObject->MaximumQuantity = 0;
$promotionObject->InstantDiscount = false;
$promotionObject->ApplyRecurring = 'NONE';
$promotionObject->RecurringChargesNumber = 3;
$promotionObject->InstantDiscount = 0;
$couponObject = new stdClass;
$couponObject->Type = 'SINGLE';
$couponObject->Code = 'single_code';
$promotionObject->Coupon = $couponObject;
$productsObj1 = new stdClass;
$productsObj1->Code = 'test';
$promotionObject->Products = [$productsObj1];
$priceMatrixDefinition1 = new stdClass;
$priceMatrixDefinition1->ProductCode = "test";
$priceMatrixDefinition1->PricingConfigurationCode = "738C6A2049";
$priceMatrixDefinition1->OptionHash = "708e43960c4edc42f14cf388bcb24bde";
$option1 = new stdClass;
$option1->GroupName = "Units";
$option1->OptionText = "1 - maximum";
$price1 = new stdClass;
$price1->Value = 10;
$price1->Currency = "USD";
$price2 = new stdClass;
$price2->Value = 15;
$price2->Currency = "EUR";
$priceMatrixDefinition1->Options = [$option1];
$priceMatrixDefinition1->Prices = [$price1, $price2];
$promotionObject->PriceMatrix = [$priceMatrixDefinition1];
$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'addPromotion',
'params' => array($sessionID, $promotionObject),
);
$result = callRPC((object)$jsonRpcRequest, $host);
var_dump($result);
Response
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"Code": "M99QQ7Q97A",
"Name": "Promo percentage REST",
"Description": "Promo description1",
"StartDate": "2019-11-30",
"EndDate": "2100-12-31",
"MaximumOrdersNumber": -1,
"MaximumQuantity": "1",
"InstantDiscount": false,
"Coupon": {
"Type": "MULTIPLE",
"Codes": [
"code1",
"code2"
]
},
"Enabled": true,
"Type": "SPECIAL_PRICE",
"Products": [
{
"Code": "test",
"PricingOptionCodes": null,
"PricingConfigurationCode": null
}
],
"Translations": [
{
"Name": "Promo percentage REST",
"Language": "EN"
}
],
"Sources": [],
"ApplyRecurring": "NONE",
"RecurringChargesNumber": "0",
"DefaultCurrency": "EUR",
"PriceMatrix": [
{
"ProductCode": "test",
"PricingConfigurationCode": "738C6A2049",
"OptionHash": "708e43960c4edc42f14cf388bcb24bde",
"Options": [
{
"GroupName": "Units",
"OptionText": "1 - maximum"
}
],
"Prices": [
{
"Value": 31.15600000000014,
"Currency": "CAD"
},
{
"Value": 20,
"Currency": "EUR"
},
{
"Value": 40,
"Currency": "USD"
},
{
"Value": 1587.5251590697817,
"Currency": "ARS"
},
{
"Value": 18541.128586270122,
"Currency": "CLP"
},
{
"Value": 18.132399999999887,
"Currency": "GBP"
},
{
"Value": 2447.1999999999794,
"Currency": "JPY"
},
{
"Value": 499.51800000000384,
"Currency": "MXN"
},
{
"Value": 97.536,
"Currency": "RON"
},
{
"Value": 1846.0500000000052,
"Currency": "RUB"
},
{
"Value": 601.8285443739301,
"Currency": "UAH"
},
{
"Value": 384.3740000000019,
"Currency": "ZAR"
}
]
}
]
}
}
Rate this article: