# Product upgrade schema

Use the **setProductUpgradeSchema** method to set a product’s upgrade schema via API.

## Request parameters

<table><thead><tr><th width="347.333251953125">Parameter</th><th>Type / Description</th></tr></thead><tbody><tr><td><code>UpgradeSettings</code></td><td><strong>Required (object)</strong><br>Details below.</td></tr><tr><td><code>UpgradeSettings.PricingScheme</code></td><td><p><strong>Required (integer)</strong><br>The Upgrade pricing scheme.</p><ol><li>Shopper pays the full upgrade product price;</li><li>Shopper pays the difference between the original subscription and the upgraded product;</li><li>Shopper pays a prorated upgrade price calculated using the most recent costs incurred by the customer;</li><li>Shopper pays prorated upgrade price calculated using the product's pricing set up at the time of the order.</li></ol></td></tr><tr><td><code>UpgradeSettings.OptionPriceOperator</code></td><td><p><strong>Optional (string)</strong><br>The operator that specifies how is the upgrade price impacted (not used for prorated upgrade pricing schemes):</p><ul><li>ADD – the value set as <code>OptionPricePercentage</code> is added to the upgrade price;</li><li>SUBTRACT – the value set as <code>OptionPricePercentage</code> is subtracted from the upgrade price.</li></ul></td></tr><tr><td><code>UpgradeSettings.OptionPricePercentage</code></td><td><strong>Optional (integer)</strong><br>The percentage of the upgrade price to be added/subtracted from this one (not used for pro-rated upgrade pricing schemes).</td></tr><tr><td><code>UseProductCatalogPricing</code></td><td><strong>Optional (boolean)</strong><br>When true, it enables the usage of product catalog pricing. Removing custom prices also disables any existing retention campaigns for the selected subscriptions.</td></tr><tr><td><code>ProrateIgnoreGracePeriod</code></td><td><strong>Optional (boolean)</strong><br>When true, it makes the grace period be ignored when calculating Upgrade. Use this option to ignore the grace period set in your Renewal Settings when computing the prorated price for the upgrade.</td></tr><tr><td><code>SubscriptionUpgradeType</code></td><td><p><strong>Required (integer)</strong><br>Determines the Subscription period option for the upgrade:</p><ol><li>Create a new subscription (disable the existing one);</li><li>Prolong the subscription from the upgrade purchase date;</li><li>The upgrade does not affect the original subscription duration. If you upgrade a lifetime subscription to a product that has recurring options, the subscription will remain lifetime, as its duration is not affected by the upgrade process.</li></ol></td></tr><tr><td><code>AllowUpgradeFrom</code></td><td><strong>Required (array of strings)</strong><br>List of product codes corresponding to the products that can be upgraded to the product of reference.</td></tr></tbody></table>

### Request sample

```php
<?php

//require_once(realpath(__DIR__ . '/../../../../../') . "/lib/api/v6.0/vendor/autoload.php");
require_once("/srv/www/app/live/htdocs/lib/api/v6.0/vendor/autoload.php");

$apiVersion = '6.0';
$domain = 'api.avangate.local:8081';
$host = "http://{$domain}/soap/{$apiVersion}/";

$client = new SoapClient($host . "?wsdl", array('location' => $host, 'cache_wsdl' => WSDL_CACHE_NONE));
$client->__setCookie('XDEBUG_SESSION', 'PHPSTORM');

// AlexB Inc account #21478
$merchantCode = "120000589445";
$key = "i9u2+w8%s4^5#8%t)A8?";
$productCode = "ADEV17962UPGRADE";            // main upgrade product offered as upgrade for other products
$upgradeFromProductCode1 = "ADEV17962UPOPT1"; // product that can be upgraded #1
$upgradeFromProductCode2 = "ADEV17962UPOPT12"; // product that can be upgraded #2

$date = gmdate('Y-m-d H:i:s');
$string = strlen($merchantCode) . $merchantCode . strlen($date) . $date;
$hash = hash_hmac('md5', $string, $key);

try {
    $sessionID = $client->login($merchantCode, $date, $hash);
} catch (SoapFault $e) {
    echo  $e->getMessage();

}
echo "SessionID: " . $sessionID . PHP_EOL;

$upgradeSchema = new stdClass();

/** @var \Api\Resources\Product\Assets\UpgradeSettings $upgradeSettings */
$upgradeSettings = new stdClass();
$upgradeSettings->PricingScheme = \Api\Resources\Product\Assets\UpgradeSettings::PRICING_SCHEME_PRICE_DIFFERENCE;
$upgradeSettings->OptionPriceOperator = \Api\Resources\Product\Assets\UpgradeSettings::OPTION_PRICE_OPERATOR_SUBSTRACT;
$upgradeSettings->OptionPricePercentage = 2;
$upgradeSettings->SubscriptionUpgradeType = \Api\Resources\Product\Assets\UpgradeSettings::SUBSCRIPTION_UPGRADE_TYPE_PROLONG_SUBSCRIPTION;
#$upgradeSettings->SubscriptionUpgradeType = 8; // invalid value
$upgradeSettings->UseProductCatalogPricing = true;
#$upgradeSettings->UseProductCatalogPricing = new SoapVar(5, XSD_INTEGER); // integer value 5 => will trigger exception
$upgradeSettings->ProrateIgnoreGracePeriod = false;

$upgradeSchema->UpgradeSettings = $upgradeSettings;
$upgradeSchema->AllowUpgradeFrom = [$upgradeFromProductCode1, $upgradeFromProductCode2];

$payload = json_encode($upgradeSchema, JSON_PRETTY_PRINT);

echo PHP_EOL . 'Calling ' . $host . ' with productCode: ' . $productCode . ' and payload: ' . PHP_EOL . $payload . PHP_EOL;

try {
    $resp = $client->setProductUpgradeSchema($sessionID, $productCode, $upgradeSchema);
} catch (SoapFault $e) {
    echo  '(SoapFault) Exception caught: ' . $e->getMessage() . PHP_EOL;
    die();
}

echo PHP_EOL . 'SetUpgradeSchema response:' . PHP_EOL . var_export($resp, true) . PHP_EOL;
```

### Response sample

```php
{
    "UpgradeSettings": {
        "PricingScheme": 1,
        "OptionPriceOperator": "ADD",
        "OptionPricePercentage": 3,
        "SubscriptionUpgradeType": 2,
        "UseProductCatalogPricing": false,
        "ProrateIgnoreGracePeriod": false
    },
    "AllowUpgradeFrom": [\
        "ADEV17962UPOPT12"\
    ]
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.2checkout.com/soap-api-reference/soap-api-6.0/api-requests/product/product-upgrade-schema.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
