Skip to main content

Search cross-sell campaigns

Search cross-sell campaigns

Last updated: 28-Nov-2022
Rate this article:

Overview

Use the searchCrossSellCampaigns call to retrieve information on the cross-sell campaigns currently defined on your account. 

Request parameters

Parameters 

Type 

Required

Description 

CampaignName 

String 

Optional 

The name of the campaign.

Status 

String 

Optional 

The status of the campaign; can be ACTIVE/INACTIVE.

Products 

Array of strings 

Optional 

Array of product codes to apply to this campaign. 

RecommendedProducts 

Array of strings 

Optional 

Array of product codes recommended to the shopper.

StartDate 

String 

Optional 

The date when the cross-sell campaign starts, formatted as YYYY-MM-DD 

EndDate 

String 

Optional 

The date when the cross-sell campaign ends, formatted as YYYY-MM-DD 

Type String Optional Can be MERCH/AFF.

Pagination 

Object 

Optional 

  

Page 

Int 

Optional 

The page number of the results.

Limit 

Int 

Optional 

The number of results per page.

Response

Parameters Type/Description
Items An array of CrossSellCampaign Objects
Pagination Pagination Object with the following parameters: Page, Limit, Count

Request sample

<?php
declare(strict_types=1);

// Start clear CLI
echo chr(27).chr(91).'H'.chr(27).chr(91).'J';
// End clear CLI

$executionStartTime = microtime(true);

$apiVersion = '6.0';
$apiHost = "http://api.avangate.local";

$host = $apiHost."/soap/" . $apiVersion . "/";

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

// Please be aware to consider valid data
$merchantCode = 'your_merchant_code';
$key = 'your_merchant_key';

// Generate hash for login
$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();
}

var_dump("Generated sessionID: ". $sessionID);
echo "\n\r";

// Build search parameters
$searchOptions = new \stdClass();

$searchOptions->Status = ['ACTIVE'];     // Optional | Ex: ['ACTIVE']
$searchOptions->Type = null;             // Optional | Ex: 'MERCH'
$searchOptions->CampaignName = null;     // Optional | Ex: 'UpdatedCampaign_4'
$searchOptions->Products = [];           // Optional | Ex: ["a01", "a02"]
$searchOptions->RecommendedProducts = [];// Optional | Ex: ["a03"]
$searchOptions->StartDate = null;        // Optional | Ex: 'YYYY-MM-DD'
$searchOptions->EndDate = null;          // Optional | Ex: 'YYYY-MM-DD'
$searchOptions->Pagination = null;       // Optional | Ex: {"Page": "1", "Limit": "10"}

try {
    $result = $client->searchCrossSellCampaigns($sessionID, $searchOptions);
    echo "\n\rSEARCH CROSS SELL CAMPAIGNS: \n\r";
    print_r(json_encode($result, JSON_PRETTY_PRINT));

} catch (SoapFault $e) {
    echo $e->getMessage();
}

$executionEndTime = microtime(true);

// The duration will be displayed in seconds and milliseconds.
$seconds = round($executionEndTime - $executionStartTime, 2);

// Print it out
echo "\n\rThis script took $seconds to execute.\n\r";

 

Rate this article:

Need help?

Do you have a question? If you didn’t find the answer you are looking for in our documentation, you can contact our Support teams for more information. If you have a technical issue or question, please contact us. We are happy to help.

Not yet a Verifone customer?

We’ll help you choose the right payment solution for your business, wherever you want to sell, in-person or online. Our team of experts will happily discuss your needs.

Verifone logo