Update promotion
Last updated: 15-Oct-2019
Rate this article:
Overview
Use the updatePromotion method to alter the details of an existing promotion.
Parameters
Parameter | Type/Description |
---|---|
sessionID | Required (string) |
Output of the Login method. | |
Promotion | Required (object) |
Promotion object that you want to update. |
Response
Parameter | Type/Description |
---|---|
Promotion | Updated promotion object. |
Request
<?php
require ('PATH_TO_AUTH');
// Retrieve promotion details
$promotionCode = 'PROMOTION_CODE'; // code of the promotion that you want to update
try {
$Discount = $client->getPromotion($sessionID, $promotionCode);
}
catch (SoapFault $e) {
echo "Discount: " . $e->getMessage();
exit;
}
var_dump("Discount", $Discount);
// Keep the promotion you want to update in $existingPromotion
try{
$existingPromotion = $client->getPromotion($sessionID, $promotionCode);
}
catch (SoapFault $e) {
echo "Existing Promotion: " . $e->getMessage();
exit;
}
// Set the fields to update
$existingPromotion->Description = 'Updated description';
// Update the promotion
try {
$updatedPromotion = $client->updatePromotion($sessionID, $existingPromotion);
}
catch (SoapFault $e) {
echo "UpdatedPromotion: " . $e->getMessage();
exit;
}
var_dump("UpdatedPromotion", $updatedPromotion);
?>
Rate this article: