Search products
Overview
Use the searchProducts method to extract information about the subscription plan/products you configured for your account.
Pagination
Use pagination to decrease the request loading time, while better handling the returning responses.
Pagination works on all the search methods existing on 2Checkout API 5.0. The default pagination behavior is to display page 1 with 10 results. The maximum number of items displayed on a single page is 200.
To use pagination, include the Pagination object inside the search method call, using the parameters below:
Parameters | Type/Description | |
---|---|---|
Pagination | Object | |
Details below. | ||
Page | Int | |
Set the number of pages that should be returned. | ||
Limit | Int | |
Set a limit for the number of results that should be returned. |
Parameters
Parameters | Type/Description | ||
---|---|---|---|
sessionID |
Required (string) |
||
|
Session identifier, the output of the Login method. Include sessionID into all your requests. 2Checkout throws an exception if the values are incorrect. The sessionID expires in 10 minutes. |
||
SearchOptions |
Object |
||
Name |
Optional (string) |
||
|
Product name. Can be NULL. |
||
|
Codes |
Optional (StringArray) |
|
|
Array of product codes. |
||
Types |
Optional (StringArray) |
||
|
Array of the values representing the type of products. Possible values:
Leave empty to have all product types returned to the search. Can be NULL. If NULL, 2Checkout returns both regular and bundle products. |
||
Enabled |
Optional (boolean) |
||
|
True or false. Can be NULL. |
||
GroupName |
Optional (string) |
||
|
The name of the group that the product is associated with. Can be NULL. |
||
Pagination | Object | ||
Limit |
Optional (integer) |
||
|
Number of results (products) displayed per page. Default value is 10. Can be NULL. |
||
Page |
Optional (integer) |
||
|
A specific page of search results. Default value is 1. Can be NULL. |
||
|
OrderBy |
Object |
|
|
Defines the order of the returned results. |
||
|
Field |
Optional (string) |
|
|
The name of the field to order the results by. Allowed values: 'ProductStatus', 'ProductName', 'ProductCode', 'UpdateDatetime', '2CheckoutId'. Can be NULL. |
||
|
Direction |
Optional (string) |
|
|
Sort results ascending or descending. Allowed values:
Can be NULL (defaults to desc).
|
Response
Parameter | Type/Description |
---|---|
Object |
Request
<?php
require ('PATH_TO_AUTH');
$SearchOptions = new stdClass();
$SearchOptions->Name = '2Checkout Subscription'; //Product name
$SearchOptions->Types = array ('REGULAR', 'BUNDLE'); //product type (standalone), regular or bundle
$SearchOptions->Enabled = True;
//$SearchOptions->GroupName = '';
$SearchOptions->Pagination = new stdClass();
$SearchOptions->Pagination->Page = 1;
$SearchOptions->Pagination->Limit = 10;
try {
$ProdSearch = $client->searchProducts($sessionID, $SearchOptions);
}
catch (SoapFault $e) {
echo "Query: " . $e->getMessage();
exit;
}
var_dump("Query", $ProdSearch);
?>