Order Methods

This topic applies to

Applies to

SuiteCommerce Web Stores

An order object holds shopping cart data and methods for placing the order. This object is different from a NetSuite order record, because it holds information for the given shopping session only.

The following Order methods are available:

addFreeGiftItem(item)

Adds the eligible item to the cart and marks it as a free item.

Parameters
  • item [required] {Object with values for fields}

    • item_id [required] {Number}

    • promotion_id [required] {Number}

    • quantity [required] {Number or String}

    • options [required for item with item options]

Note: quantity can be a negative number.

Returns

String - the orderitemid of added item.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

addItem(item)

Adds an item to order.

Note

If your selected Out Of Stock Behavior option is Disallow back orders but display out-of-stock message or Remove out-of-stock items from store, you might still be able to add an out of stock item to your cart using the addItem(item) order method. However, when you try to place the order with such out of stock item in your shopping cart, an error message is displayed and you will not be able to place the order successfully.


Parameters
  • item [required] {Object with values for fields}

    • internalid [required]

    • quantity [required] {Number or String}

    • options [required for item with item options]

    • fulfillmentPreferences [optional] {fulfillmentPreferences object}

Note: quantity can be a negative number.

Returns

String - the orderitemid of added item.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

addItems(items)

Adds multiple items to cart/order within a single request.

Note

If your selected Out Of Stock Behavior option is Disallow back orders but display out-of-stock message or Remove out-of-stock items from store, you might still be able to add out of stock items to your cart using the addItems(items) order method. However, when you try to place the order with such out of stock items in your shopping cart, an error message is displayed and you will not be able to place the order successfully.


Parameters
  • items [required]{Array of objects with values for fields}

    • internalid [required]

    • quantity [required] {Number or String}

    • options [required for item with item options]

    • fulfillmentPreferences [optional] {fulfillmentPreferences object}

Returns

String - the orderitemid of added items.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

applyGiftCertificate(giftcertificate)

Applies given gift certificate to the order.

Parameters
  • giftcertificate [required] {String}

Returns

No value returned.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

applyPromotionCode(promocode)

Applies given promotion code to the order.

Parameters
  • promocode [required] {String}

Returns

No value returned.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

estimateShippingCost(address)

Gets estimated shipping cost for given address.

Note

Estimated shipping cost depends on order's shipping method, enabling of shipping estimator on site administration page, and whether order requires shipping.


Parameters
  • address [optional] {Object with fields}

    • zip [required]

    • country [required]

    • state [optional]

Returns

Number

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

setItemExcludedFromShipping(cartItemId,excluded)

Identifies when an item on an order is excluded from shipping.

Parameters
  • cartItemId [required] {string}

  • excluded [required] {boolean}

Returns

No value returned.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

getAppliedGiftCertificate(giftcertificate, fields)

Gets specified gift certificate.

Parameters
  • giftCertificate [required] Certificate(giftcertificate, fields)

  • fields [optional] Array of field names to be included in returned JSON object; if omitted, all supported fields are returned}

Returns

Object of type giftcertificate.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

getAppliedGiftCertificates(fields)

Gets all applied gift certificates.

Parameters
  • fields [optional] Array of field names to be included in returned JSON object; if omitted, all supported fields are returned}

Returns

Array of objects of type giftcertificate

Supported Domains

Checkout

Login Required?

No

Back toOrder Methods | Back toShopping Objects

getAppliedPromotionCode(promocode, fields)

Gets specified promotion code.

Parameters
  • promoCode [required] {String}

  • fields [optional] Array of field names to be included in returned JSON object; if omitted, all supported fields are returned}

Returns

Object of type promocode

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

getAppliedPromotionCodes(fields)

Gets all applied promotion codes.

Parameters
  • fields [optional] Array of field names to be included in returned JSON object; if omitted, all supported fields are returned}

Returns

Array of objects of type promocode.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

getAvailableShippingMethods(orderLineIds, shipAddressId)

Returns available shipping methods and addresses for the given item in the order.

Note

The setEnableItemLineShipping() flag must be set before using this method. See setEnableItemLineShipping().


Parameters
  • orderLineIds [required] Array of orderitemids to merge

  • shipAddressId [required] String

Returns

Array of objects of type shipmethod.

Supported Domains

Checkout

Login Required?

No

Back toOrder Methods | Back toShopping Objects

getAvailableShippingMethod(shipmethodid,fields)

Gets specified shipping method.

Parameters
  • shipmethodid [required] {String}

  • fields [optional] Array of field names to be included in returned JSON object; if omitted, all supported fields are returned}

Returns

Object of type shipmethod.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

getAvailableShippingMethods(fields)

Gets all available shipping methods.

Parameters
  • fields [optional] Array of field names to be included in returned JSON object; if omitted, all supported fields are returned}

Returns

Array of objects of type shipmethod.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

getBillingAddress()

Gets billing address for order.

Parameters

No parameters to set.

Returns

Object of type address.

Supported Domains

Checkout

Login Required?

Yes

Back toOrder Methods | Back toShopping Objects

getCustomFields()

Gets custom fields on order record.

Parameters

No parameters to set.

Returns

Object with custom field names.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

getCustomFieldValues()

Gets custom field values for current order.

Parameters

No parameters to set.

Returns

Object with custom field values.

Supported Domains

Checkout, Shopping

Login Required?

Yes

Back toOrder Methods | Back toShopping Objects

getDeviceFingerPrintingHtml()

Sets device finger printing for CyberSource for the device a shopper is logged in from when accessing a web store. This can be used with the Cybersource payment gateway for added site security. The API call must be made in the last step of checkout. For more details on device fingerprinting in SuiteCommerce Advanced sites, see Device Fingerprinting.

Parameters

No parameters to set.

Returns

Returns an HTML string that needs to be rendered on the last page of a checkout that includes the Submit Order button.

Supported Domains

Checkout

Login Required?

Yes

Back toOrder Methods | Back toShopping Objects

getEligibleFreeGiftItems()

Gets a list of all Free Item promotions that are currently applied. It also gets the Item IDs of all the free items.

Parameters

No parameters to set.

Returns

Array of objects with the following fields:

  • promotion_id

  • eligible_items

  • eligible_quantity

  • rejected_quantity

  • added_quantity

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

getFieldValues(fields)

Gets standard field values for the current order.

Parameters
  • fields [optional] Array of field names to be included in returned JSON object; if omitted, all supported fields are returned}

Returns

Object of type order.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

getItem(orderitemid, fields)

Gets specified order item.

Parameters
  • orderitemid [required] {String}

  • fields [optional] Array of field names to be included in returned JSON object; if omitted, all supported fields are returned}

Returns

Object of type orderitem.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

getItemOption(orderitemid,fields)

Gets item option for specified order item.

Parameters
  • orderitemid [required] {String}

  • fields [optional] Array of field names to be included in returned JSON object; if omitted, all supported fields are returned}

Returns

The options field from the object of type orderitem.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

getItems(bConsolidated), getItems(fields, bConsolidated)

Used to configure multiple shipping routes on web orders. Depending on the value for bConsolidated, order items are returned in either a split view or in a consolidated view.

For example, displaying an un-consolidated view of all the items in the cart allows shoppers to select the shipping address for each item. You can then use the consolidated view to display items to be shipped, grouped by shipping address.

Note

The setEnableItemLineShipping() flag must be set before using this method. See setEnableItemLineShipping().


Parameters
  • bConsolidated Boolean

  • fields Array of field names to be included in returned JSON object; if omitted, all supported fields are returned

Returns

Object of type orderitem.

Supported Domains

Checkout

Login Required?

No

Back toOrder Methods | Back toShopping Objects

getItems(fields)

Gets order items.

Parameters
  • fields [optional] Array of field names to be included in returned JSON object; if omitted, all supported fields are returned}

Returns

Array of objects of type orderitem.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

getItemShippingFieldValues(orderitemid)

Gets shipping field values for specified order item. This API is only available when the Multiple Shipping Routes feature is enabled.

Parameters
  • orderitemid [required] {String}

Returns

Object with fields:

  • shipaddress

  • shipmethod

Supported Domains

Checkout

Login Required?

Yes

Back toOrder Methods | Back toShopping Objects

getOrderSummary(fields)

Gets the order summary.

Important

For the most optimized results, use the itemcount argument with this method. When this method is called with no arguments, all information about the order is returned which results in poor performance.


Example

var itemcount = nlapiGetWebContainer().getShoppingSession().getOrder().getOrderSummary(['itemcount']);
Parameters
  • fields [optional] Array of field names to be included in returned JSON object; if omitted, all supported fields are returned}

Returns

Object of type ordersummary.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

getPayment(fields)

Gets payment details for order.

Parameters
  • fields [optional] Array of field names to be included in returned JSON object; if omitted, all supported fields are returned}

Returns

Object of type payment.

Supported Domains

Checkout

Login Required?

Yes

Back toOrder Methods | Back toShopping Objects

getPurchaseNumber() 

Gets the Purchase order number associated with the order.

Parameters

No parameters to set.

Returns

String

Supported Domains

Checkout

Login Required?

Yes

Back toOrder Methods | Back toShopping Objects

getShippingAddress()

Gets shipping address for order.

Parameters

No parameters to set.

Returns

Object of type address

Supported Domains

Checkout

Login Required?

Yes

Back toOrder Methods | Back toShopping Objects

getShippingMethod(fields)

Gets shipping method for order.

Parameters
  • fields [optional] Array of field names to be included in returned JSON object; if omitted, all supported fields are returned}

Returns

Object of type shipmethod.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

mergeItems(orderLineIds)

Merges the given line items into a single order line item. The given order lines can only differ in quantity and shipping address and method.

Note

The setEnableItemLineShipping() flag must be set before using this method. See setEnableItemLineShipping().


Parameters
  • orderLineIds[required]: Array of orderitemids to merge

Returns

No value returned.

Supported Domains

Checkout

Login Required?

Yes

Sample Code
nlapiGetWebContainer().getShoppingSession().getOrder().mergeItems(orderLineIds);

Back toOrder Methods | Back toShopping Objects

rejectFreeGiftItem(item)

Allows shoppers to reject the free item provided the item is not already in the cart.

Parameters
  • item [required] {Object with values for fields}

    • promotion_id [required] {Number}

    • quantity [required] {Number or String}

Note: quantity can be a negative number.

Returns

No value returned.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

removeAllGiftCertificates()

Removes all gift certificates from an order.

Parameters

No parameters to set.

Returns

No value returned.

Supported Domains

Checkout, Shopping

Login Required?

No

Sample Code
nlapiGetWebContainer().getShoppingSession().getOrder().removeAllGiftCertificates()

Back toOrder Methods | Back toShopping Objects

removeAllItems()

Removes all items from order.

Parameters

No parameters to set.

Returns

No value returned.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

removeBillingAddress()

Removes the current billing address from the order.

Parameters

No parameters to set.

Returns

No value returned.

Supported Domains

Checkout

Login Required?

yes

Back toOrder Methods | Back toShopping Objects

removeItem(orderitemid)

Removes specified item from order.

Parameters
  • orderitemid [required] {String}

Returns

No value returned.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

removeItemOptions(itemlineid)

Removes specified item options from a row in the cart.

Parameters
  • itemlineid [required]

Returns

No value returned.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

removePayment()

Removes the current payment method for the order.

Parameters

No parameters to set.

Returns

No value returned.

Supported Domains

Checkout

Login Required?

Yes

Back toOrder Methods | Back toShopping Objects

removePurchaseNumber()

Removes the associated Purchase order number from order.

Parameters

No parameters to set.

Returns

No value returned.

Supported Domains

Checkout

Login Required?

Yes

Back toOrder Methods | Back toShopping Objects

removePromotionCode(promocode)

Removes specified promotion code from order.

Parameters
  • promocode [required] {String}

Returns

No value returned.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

removeAllPromotionCodes()

Removes all promotion codes from the order.

Parameters

No parameters to set.

Returns

No value returned.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

removeShippingAddress()

Removes the current shipping address from the order.

Parameters

No parameters to set.

Returns

No value returned.

Supported Domains

Checkout

Login Required?

Yes

Back toOrder Methods | Back toShopping Objects

removeShippingMethod()

Removes the current shipping method for the order.

Parameters

No parameters to set.

Returns

No value returned.

Supported Domains

Checkout

Login Required?

Yes

Back toOrder Methods | Back toShopping Objects

setBillingAddress(addressid)

Sets the billing address for the order.

Parameters
  • addressid [required] {String}

Returns

No value returned.

Supported Domains

Checkout

Login Required?

Yes

Back toOrder Methods | Back toShopping Objects

setCustomFieldValues(customfields)

Sets custom field values for order.

Parameters
  • customfields [required] {Object with name/value pair for each field}

Important

Custom fields of the type Document are NOT supported for non-Employee external centers.


Returns

No value returned.

Supported Domains

Checkout

Login Required?

Yes

Back toOrder Methods | Back toShopping Objects

setEnableItemLineShipping()

Toggles the item line shipping flag for the current order. This flag must be set prior to using other Multiple Ship To APIs.

Important

The Multiple Shipping Routes feature is required.


An exception is thrown when:

  • The Multiple Shipping Routes feature is not enabled

  • The site is not using the Standard Sales Order Form for scripting

Parameters
  • enable [required]: Boolean

Returns

No value returned.

Supported Domains

Checkout

Login Required?

Yes

Sample Code
nlapiGetWebContainer().getShoppingSession().getOrder().setEnableItemLineShipping(true);

Back toOrder Methods | Back toShopping Objects

setItemOptions(itemlineid,optionMap)

Updates the item options for a particular cart row.

Parameters
  • itemlineid [required]

  • optionMap [required] {Array of Item Option ID value pairs}

Note

itemlineid is a combination of item id and set. This is included because of the possibility for multiple quantities of the same item but with different item options.


Returns

itemLineId of the new line with the new item options.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

setItemShippingAddress(orderItemId, shipAddressId)

Sets the shipping address for the given order line item.

Note

The setEnableItemLineShipping() flag must be set before using this method. See setEnableItemLineShipping().


Parameters
  • orderItemId[required]: String

  • shipAddressId[required]: String

Returns

No value returned.

Supported Domains

Checkout

Login Required?

Yes

Sample Code
nlapiGetWebContainer().getShoppingSession().getOrder().setItemShippingAddress(orderItemId, shipAddressId);

Back toOrder Methods | Back toShopping Objects

setItemShippingAddress(orderItemIds, shipAddressId)

Sets the shipping address for an array of given order line items.

Note

The setEnableItemLineShipping() flag must be set before using this method. See setEnableItemLineShipping().


Parameters
  • orderItemIds[required]: Array of orderItemId fields.

  • shipAddressId[required]: String

Returns

No value returned.

Supported Domains

Checkout

Login Required?

Yes

Back toOrder Methods | Back toShopping Objects

setItemShippingMethod(orderItemId, shipMethodId)

Sets the shipping method for the given order line item.

Note

The setEnableItemLineShipping() flag must be set before using this method. See setEnableItemLineShipping().


Parameters
  • orderItemId[required]: String.

  • shipMethodId[required]: String

Returns

No value returned.

Supported Domains

Checkout

Login Required?

Yes

Sample Code
nlapiGetWebContainer().getShoppingSession().getOrder().setItemShippingMethod(orderItemId, shipMethodId);

Back toOrder Methods | Back toShopping Objects

setItemShippingMethod(orderItemIds, shipMethodId)

Sets the shipping method for an array of given order line items.

Note

The setEnableItemLineShipping() flag must be set before using this method. See setEnableItemLineShipping().


Parameters
  • orderItemIds[required]: Array of orderItemId fields.

  • shipMethodId[required]: String

Returns

No value returned.

Supported Domains

Checkout

Login Required?

Yes

Back toOrder Methods | Back toShopping Objects

setPayment(payment)

Sets payment for order; for credit card, creates a new record if internalid not provided.

Parameters
  • payment [required] {Object with values for fields}

    • internalid [optional]

    • *ccname [optional]

    • *ccnumber [optional]

    • *expmonth [optional]

    • *expyear [optional]

    • paymentmethod[required]

    • paymentterms[optional]

  • creditcard [required] (this is an object within the payment object.)

Note

* Fields are required only for credit card payment methods.


For information on creating non-credit card payment methods, see Alternative Credit Card Payment Methods.

Returns

No value returned.

Supported Domains

Checkout

Login Required?

Yes

Back toOrder Methods | Back toShopping Objects

setPurchaseNumber(purchaseNumber) 

Sets the purchase number for the order.

Parameters
  • purchaseNumber [required] {String}

Returns

No value returned.

Supported Domains

Checkout

Login Required?

Yes

Back toOrder Methods | Back toShopping Objects

setShippingAddress(addressid)

Sets the shipping address for the order.

Parameters
  • addressid [required] {String}

Returns

No value returned.

Supported Domains

Checkout

Login Required?

Yes

Back toOrder Methods | Back toShopping Objects

setShippingMethod(shipmethod)

Sets shipping method for order.

Parameters
  • shipmethod [required] {Object with values for fields}

    • shipmethod [required]

    • shipcarrier [required]

      Note

      Valid values that can be set for shipcarrier are ups or noups.


Returns

No value returned.

Supported Domains

Checkout

Login Required?

Yes

Back toOrder Methods | Back toShopping Objects

setTermsAndConditions(readandagree)

If required by site, sets whether user has read and agreed to terms and conditions.

Parameters
  • readandagree [required] {Boolean}, or {String}, where value must be “T” or “F”

Returns

No value returned.

Supported Domains

Checkout

Login Required?

Yes

Back toOrder Methods | Back toShopping Objects

splititem(orderLine)

Splits the given line item into multiple order line items. You can then set a shipping address for each order line.

Note

The setEnableItemLineShipping() flag must be set before using this method. See setEnableItemLineShipping().


Parameters
  • orderLine [required] {Object with values for fields}

    • orderitemid [required]

    • quantities [optional]  An array of quantities to split into. If not provided, all of the line items from the split are given a quantity of 1.

Returns

No value returned.

Supported Domains

Checkout

Login Required?

Yes

Sample Code
nlapiGetWebContainer().getShoppingSession().getOrder().splitItem(orderitem);

Back toOrder Methods | Back toShopping Objects

submit(ordersettings)

Places the shopping order.

Parameters
Returns

Object with fields:

  • status

  • internalid

  • confirmationnumber

Supported Domains

Checkout

Login Required?

Yes

Back toOrder Methods | Back toShopping Objects

updateItemFulfillmentPreferences(item)

Updates specified item's fulfillment choices for the order.

Parameters
  • item [required] {Object with values for fields}

    • orderitemid [required]

    • fulfillmentPreferences [required] {fulfillmentPreferences object}

Returns

No value returned.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

updateItemsFulfillmentPreferences(items)

Updates specified items' fulfillment choices for the order.

Parameters
  • items [required] {Array of objects with values for fields}

    • orderitemid [required]

    • fulfillmentPreferences [required] {fulfillmentPreferences object}

Returns

No value returned.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

updateItemQuantity(item)

Updates specified item's quantity for order.

Parameters
  • item [required]{Object with values for fields}

    • orderitemid [required]

    • quantity [required] {Number or String}

Returns

No value returned.

Supported Domains

Checkout, Shopping

Login Required?

No

Back toOrder Methods | Back toShopping Objects

updateItemQuantities(items)

Updates specified items' quantities for order.

Parameters
  • items [required]{Array of objects with values for fields}

    • orderitemid [required]

    • quantity [optional] {Number or String} Defaults to 1 if omitted.

Returns

No value returned.

Supported Domains

Checkout, Shopping

Login Required?

No