Language

2Checkout Documentation

Update Option

The update_option call is used to update an option.

URL: https://www.2checkout.com/api/products/update_option

HTTP Method: POST


Input Parameters

Parameter Description
option_id ID of option being updated. Required.
option_name Name of new product option. Required.
option_value_id ID of existing option value to update/delete. Required when updating/deleting an option value.
option_value_name Name of option value. Required when creating an option value.
option_value_surcharge Amount of option surcharge. Required when creating an option value surcharge.

Data Returned

Parameter Description
response_code Tells the user whether or not the operation was successful.
response_message Tells the user why the operation was or was not successful.

Example API Call

Twocheckout::username('APIuser1817037');
Twocheckout::password('APIpass1817037');

$args = array(
    'option_id' => 4836975248,
    'option_name' => 'New Option Name'
);

$result = Twocheckout_Option::update($args);
Twocheckout::API.credentials = { :username => 'APIuser1817037', :password => 'APIpass1817037' }

option = Twocheckout::Option.create({:option_name => "test option", :option_value_name => "test option value", :option_value_surcharge => 1.00})
option.update(:option_name => "new name")
args = {
    option_name: "test option",
    option_value_name: "value name",
    option_value_surcharge: "0.01"
};

tco.productOptions.update(args, function (error, data) {
    if (error) {
        console.log(error);
    } else {
        console.log(data.response_code);
    }
});
twocheckout.Api.credentials({'username':'APIuser1817037', 'password':'APIpass1817037'})

params = {
    'option_id': 4837092437
    }

option = twocheckout.Option.find(params)

params = {
    'option_name': 'test option'
    }

option = option.update(params)
var ServiceObject = new OptionService();
var ArgsObject = new OptionUpdateServiceOptions();
ArgsObject.option_id = option_id;
ArgsObject.option_name = "Test Option 123";
ArgsObject.option_value_name = "Test Option Value 123";
ArgsObject.option_value_surcharge = (decimal)1.00;

var result = ServiceObject.Update(ArgsObject);
ProductOption option = TwocheckoutOption.retrieve(option_id);
option.setOptionName("test");
TwocheckoutResponse result = option.update();
curl -X POST https://www.2checkout.com/api/products/update_option \
    -H 'Accept: application/json' -u 'username:password' \
    -d 'option_id=1001' -d 'option_name=test option' -d 'option_value_name=colors'
    -d 'option_value_surcharge=1.00'

Example Successful Response

    {
       "response_code" : "OK",
       "response_message" : "Option updated successfully"
    }

 


Common Error Codes

Code Description
PARAMETER_MISSING Required parameter missing:
PARAMETER_INVALID Invalid value for parameter:
RECORD_NOT_FOUND Unable to find record.
FORBIDDEN Access denied to option.