Retrieve recommended upsell campaign

Use the getRecommendedUpsellCampaign method via JSON-RPC API 6.0 to find a campaign for the product code and the other sent filters.

Request parameters

Parameter
Type / Description

SessionId

Required (string)

Unique 2Checkout session ID code.

ProductCode

Required (string)

The primary product code.

Quantity

Optional (integer)

The product quantity.

PriceOptions

Optional (string)

The price options for the primary product.

EnabledForRenewals

Optional (boolean)

Returns only upsell campaigns that are enabled (or not) for renewals.

Request sample

<?php

require('PATH_TO_AUTH');

$productCode = 'upsell_module_po';
$quantity = 13;
$priceOptions = 'option1,module_scale_po2=5';
$enabledForRenewals = true;

$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'getRecommendedUpsellCampaign';
$jsonRpcRequest->params = [$sessionID, $productCode, $quantity, $priceOptions, $enabledForRenewals];
$jsonRpcRequest->id = $i++;

$resp = callRPC($jsonRpcRequest, $host);
$response = json_encode($resp, JSON_PRETTY_PRINT);
echo PHP_EOL . 'getRecommendedUpsellCampaign response:' . PHP_EOL . var_export($resp, true) . PHP_EOL;

Response parameters

Parameters
Type / Description

Object

Object containing information related to the upsell campaigns, including product information and discount settings.

Last updated

Was this helpful?