Update special price promotion
Last updated: 12-Nov-2020
Rate this article:
Overview
Use the UpdateSpecialPricePromotion method to modify promotion at a special price.
Request parameters
Parameters | Type | Required | Description |
---|---|---|---|
promotionCode | String | Required | Code of the promotion that you want to update. |
sessionID | String | Required | Unique identifier of the session. |
existingPromotion | String | Required | Details of the existing promotion. |
PriceMatrix | Array of Objects | Required | Only for this type of promotion. It is generated by getPriceMatrix and used to set promotion special prices. |
Request sample
<?php
require ('PATH_TO_AUTH');
// Retrieve promotion details
$promotionCode = 'PROMOTION_CODE'; // code of the promotion that you want to update
$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'getPromotion',
'params' => array($sessionID, $promotionCode)
);
//var_dump (callRPC((Object)$jsonRpcRequest, $host));
// Keep the promotion you want to update in $existingPromotion
$existingPromotion = callRPC((Object)$jsonRpcRequest, $host);
// Set the fields to update
$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 = 20;
$price1->Currency = "USD";
$price2 = new stdClass;
$price2->Value = 15;
$price2->Currency = "EUR";
$priceMatrixDefinition1->Options = [$option1];
$priceMatrixDefinition1->Prices = [$price1, $price2];
$existingPromotion->DefaultCurrency = 'USD';
$existingPromotion->PriceMatrix = [
$priceMatrixDefinition1
];
// Update the promotion
$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'updatePromotion',
'params' => array($sessionID, $existingPromotion)
);
var_dump (callRPC((Object)$jsonRpcRequest, $host));
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: