Skip to content

Product_Retrieve

Craig Christenson edited this page Oct 26, 2012 · 2 revisions

2Checkout's back office API allows you to retrieve product information. You must specify your API username and password using the the Twocheckout::setCredentials method before calling a method in this class. The Twocheckout_Product class provides methods to create, retrieve, update and delete products and will return a JSON object or array depending on your specification.

##Method

###retrieve

Use to retrieve a product.

####Arguments

  • array Array

  • Array containing list_products parameters or just a product_id. Parameters -> API List Products

  • string format

  • Supports 'json' or 'array'. Defines response format. Default: 'json'

####Returns

Returns a JSON object or array depending on your specification.

####Example Usage:

<?php

Twocheckout::setCredentials("APIuser1817037", "APIpass1817037");

$args = array(
    'product_id' => 4838125968
);

$result = Twocheckout_Product::retrieve($args, 'array');

print_r($result);

####Example Response:

Array
(
    [product] => Array
        (
            [approved_url] => 
            [assigned_product_id] => 445
            [categories] => Array
                (
                )

            [commission] => 0
            [commission_amount] => 
            [commission_type] => 
            [description] => This is an example description
            [duration] => 
            [handling] => 
            [images] => Array
                (
                )

            [long_description] => 
            [name] => Example Product
            [options] => Array
                (
                )

            [pending_url] => 
            [price] => 1.00
            [product_id] => 4838125968
            [recurrence] => 
            [recurrence_p] => 
            [recurring] => 0
            [startup_fee] => 
            [tangible] => 0
            [vendor_id] => 1817037
            [vendor_product_id] => 
            [weight] => 
        )

    [response_code] => OK
    [response_message] => Product detail information retrieved successfully
)
Clone this wiki locally