This object represents an option on one of the items in the shopping cart. See item configuration for details on managing items.
Local currency fields are only available to the REST API.
Field | Type | Description | Required when adding an item to cart |
name | string | Option name | YES |
selectedValue | string | Seleted value on the option | YES |
| |||
costPerLetter costPerLetterLocalized costPerLetterLocalizedFormatted | number number string | Fee per letter specified in a single or multiline option | NO |
costPerLine costPerLineLocalized costPerLineLocalizedFormatted | number | Fee per line of text specified in a multiline option | NO |
costIfSpecified costIfSpecifiedLocalized costIfSpecifiedLocalizedFormatted | number | Fee if specified | NO |
ignoreIfDefault | boolean | True if option will be ignored on the order if the default value is selected | NO |
label | label | Option display label | NO |
oneTimeFee | boolean | True if the fee is only applied once (irregardless of quantity) | NO |
optionOid | integer | A unique option object identifier. This is provided to easy debugging with UltraCart premium support. | NO |
required | boolean | True if required | NO |
type | string | Type of option. See OPTION_TYPE_ constants in the checkoutapi.js for a list of valid values. | NO |
values | Values that the customer can select from for radio or drop down style options | NO | |
Short Example of creating a CartItem with options:
// create my cart item. just the bare required properties: itemId, quantity.
// see: http://docs.ultracart.com/display/ucdoc/CartItem
var item = {'itemId': myItem.itemId, 'quantity': 1};
item.options = []; // create the (initially empty) options placeholder.
var opt = {'name': 'Option1', 'selectedValue': 'Large'};
item.options.push(opt);
opt = {'name': 'Option2', 'selectedValue': 'Skittles'};
item.options.push(opt);
// add items takes an array. I've only got one item, so I'll surround it by brackets to create a single element array.
ultraCart.addItems([item]);
Full example of downloading an item from the server, creating select boxes for it, and then adding an item with options to a cart:
(You may download this example as a zip file. See this page's attachments.)