Save prices
Request parameters
Parameter
Type / Description
Request sample
<?php
require ('PATH_TO_AUTH');
/**
* ProductCode = 'PDOWNFILE'
* Default currency: EUR
*
* Dynamic pricing configuration
*
* Send two prices, including the required one for the default currency
* The method will append the prices for the sent entries, without removing the previous values
*
* If the quantities intervals were not defined then they will be set.
* If the quantities overlap with existing defined intervals, an Exception will be thrown.
*/
// make call
$Prices = array();
$Price = new stdClass(); // BasicPrice object
$Price->Amount = 140;
$Price->Currency = 'USD';
$Prices[] = $Price;
$Price = new stdClass(); // BasicPrice object
$Price->Amount = 80;
$Price->Currency = 'EUR';
$Prices[] = $Price;
$Quantities = new stdClass(); // QuantityInterval object
$Quantities->MinQuantity = 1;
$Quantities->MaxQuantity = 10;
$PriceOptions = array();
$PricingConfigurationCode = '5553603382';
$type = 'regular';
$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'savePrices',
'params' => array($sessionID, $Prices, $Quantities, $PriceOptions, $PricingConfigurationCode, $type)
);
$response = callRPC((Object)$jsonRpcRequest, $host);
var_dump ($response);
// will output:
// bool(true)
/**
* ProductCode = 'PDOWNFILE'
* Default currency: EUR
*
* Flat pricing configuration
* Has the VOLTAGE pricing option group assigned and marked as required.
* If prices are sent WITHOUT setting the pricing option group and options will set the price but without setting values for the options prices.
*/
// Call the login method for authentication
$string = strlen($merchantCode) . $merchantCode . strlen(gmdate('Y-m-d H:i:s')) . gmdate('Y-m-d H:i:s');
$hash = hash_hmac('md5', $string, $key);
$i = 1; // counter for api calls
$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'login';
$jsonRpcRequest->params = array($merchantCode, gmdate('Y-m-d H:i:s'), $hash);
$jsonRpcRequest->id = $i++;
$sessionID = callRPC($jsonRpcRequest, $host);
// make call
$Prices = array();
$Price = new stdClass(); // BasicPrice object
$Price->Amount = 80;
$Price->Currency = 'EUR';
$Prices[] = $Price;
// if PricingOption group is not required, will set price for combination of QuantityInterval - no-pricing-option-value.
$PriceOptions = array();
// if PricingOption group is required, then send options by assigning a PriceOptionsAssigned object (group code and options)
// $optionAssigned = new stdClass(); // PriceOptionsAssigned
// $optionAssigned->Code = 'VOLTAGE';
// $optionAssigned->Options = array('220V'); // radio option group
// $PriceOptions = array($optionAssigned);
$Quantities = new stdClass(); // QuantityInterval object
$Quantities->MinQuantity = 1;
$Quantities->MaxQuantity = 99999; // default maximum value
$PricingConfigurationCode = '54AA62CA31'; // flat pricing configuration
$type = 'regular';
$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'savePrices',
'params' => array($sessionID, $Prices, $Quantities, $PriceOptions, $PricingConfigurationCode, $type)
);
$response = callRPC((Object)$jsonRpcRequest, $host);
var_dump ($response);
/**
* ProductCode = 'PDOWNFILE'
* Default currency: EUR
*
* Flat pricing configuration
* Has the COLOR and scalenotmandatory pricing option group assigned and marked as required.
*/
// Call the login method for authentication
$string = strlen($merchantCode) . $merchantCode . strlen(gmdate('Y-m-d H:i:s')) . gmdate('Y-m-d H:i:s');
$hash = hash_hmac('md5', $string, $key);
$i = 1; // counter for api calls
$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'login';
$jsonRpcRequest->params = array($merchantCode, gmdate('Y-m-d H:i:s'), $hash);
$jsonRpcRequest->id = $i++;
$sessionID = callRPC($jsonRpcRequest, $host);
// make call
$Prices = array();
$Price = new stdClass(); // BasicPrice object
$Price->Amount = 10;
$Price->Currency = 'EUR';
$Prices[] = $Price;
$optionAssigned = new stdClass(); // PriceOptionsAssigned
$optionAssigned->Code = 'COLOR'; // checkbox pricing option group, multiple values are allowed
$optionAssigned->Options = array('cyan', 'magenta');
$PriceOptions = array($optionAssigned);
$optionAssigned = new stdClass(); // PriceOptionsAssigned
$optionAssigned->Code = 'scalenotmandatory'; // interval pricing option group
$optionAssigned->Options = array('scalenotmandatory-1-5');
$PriceOptions = array($optionAssigned);
$Quantities = new stdClass(); // QuantityInterval object
$Quantities->MinQuantity = 1;
$Quantities->MaxQuantity = 99999; // default maximum value
$PriceOptions = array();
$PricingConfigurationCode = '54AA62CA31'; // flat pricing configuration
$type = 'regular';
$jsonRpcRequest = array (
'jsonrpc' => '2.0',
'id' => $i++,
'method' => 'savePrices',
'params' => array($sessionID, $Prices, $Quantities, $PriceOptions, $PricingConfigurationCode, $type)
);
$response = callRPC((Object)$jsonRpcRequest, $host);
var_dump ($response);
?>Response
Last updated
Was this helpful?