Skip to content

Option_Retrieve

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

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

##Method

###retrieve

Use to retrieve an option.

####Arguments

  • array Array

  • Array containing list_options parameters or just a option_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(
    'option_id' => 4836975248
);

$option = Twocheckout_Option::retrieve($args, 'array');

print_r($option);

####Example Response:

Array
(
    [option] => Array
        (
            [0] => Array
                (
                    [option_id] => 4836975248
                    [option_name] => Example Option
                    [option_values] => Array
                        (
                            [0] => Array
                                (
                                    [option_value_id] => 4836975251
                                    [option_value_name] => Test1
                                    [option_value_surcharge] => 1.00
                                )

                            [1] => Array
                                (
                                    [option_value_id] => 4836975266
                                    [option_value_name] => Test2
                                    [option_value_surcharge] => 1.00
                                )

                        )

                )

        )

    [response_code] => OK
    [response_message] => Option detail retrieved successfully.
)
Clone this wiki locally