embedded.carts.get.after

Description

This action occurs after a GET operation is run against the cart, with the exception of getting cart summaries. Changes made to the cart or cart items in this action persist in Kibo eCommerce.

Action Type Embedded
Full Action ID embedded.commerce.carts.get.after
Runs multiple custom functions? No

JavaScript File Structure

Action files share the following basic structure:

module.exports = function(context, callback) {
	// Your custom code here
	callback();
};
			

When you code the custom function for an action, you have access to two arguments:

callback—This argument follows the established JavaScript callback pattern: it takes an error as the first argument (or null if there is no error) and a result as the second argument (if required).

context—This argument provides the function access to relevant objects and methods that interface with Kibo eCommerce.

Context: Cart

The following methods and objects are available to this action through the use of the context argument.

Microservice Operation
This action corresponds to the microservice that gets a cart.


Get Methods

Exec Methods

Context Objects Available to All Actions

Get

get.cart
Obtains a response that includes information about the current cart.
Parameters Type Description
N/A N/A N/A

Example:

context.get.cart();

Response:

For information about the properties in the response, refer to the REST API Help.



Exec

exec.setData
Sets custom key/value data on the current cart.
Parameters Type Description
key string Key of the data to set on the cart.
value object Value of the data to set.

Example:

context.exec.setData("customField", value);

Response:

For information about the properties in the response, refer to the REST API Help.





exec.removeData
Removes custom key/value data from the specified cart.
Parameters Type Description
key string Key of the data to remove from the cart.

Example:

context.exec.removeData("customField");

Response:

For information about the properties in the response, refer to the REST API Help.





exec.setItemData
Sets custom key/value data on a cart item.
Parameters Type Description
key string Key of the data to set on the cart item.
value object Value of the data to set.
itemId string Id of the cart item to which the data is applied.

Example:

context.exec.setItemData("customField", value, "123");

Response:

For information about the properties in the response, refer to the REST API Help.





exec.removeItemData
Removes custom key/value data from a cart item.
Parameters Type Description
key string Key of the data to remove from the cart item.
itemId string Id of the item from which to remove data if applied to a line item that is not the current line item. Current line item only applies when called from a cart item action.

Example:

context.exec.removeItemData("customField", "123");

Response:

For information about the properties in the response, refer to the REST API Help.





exec.setItemAllocation
Sets soft allocation information on a cart item.
Parameters Type Description
allocationId int Id of the allocation to set on the cart item.
expiration date/time Date/time of the allocation expiration.
productCode string Code of the product or product variation that is allocated.
itemId string Id of the item to set the allocation on if applied to a line item that is not the current line item. Current line item only applies when called for a cart item action.

Example:

context.exec.setItemAllocation(5, dateVariable, "LUC-SAMPLE-PROD", "123");

Response:

For information about the properties in the response, refer to the REST API Help.





exec.removeItem
Removes an item from the cart.
Parameters Type Description
itemId string Id of the item to remove.

Example:

context.exec.removeItem("123");

Response:

For information about the properties in the response, refer to the REST API Help.



Context Objects Available to All Actions

apiContext

Acesses Kibo eCommerce tenant information.

Properties Type Description
baseUrl string The base URL for the site.
basePciUrl string The base PCI URL for the site.
tenantPod string The name of the tenant pod in which the tenant resides.
appClaims string The application claims token.
appKey string The application key.
tenantId integer Unique identifier for the tenant.
siteId integer Unique identifier for the site. This ID is used at all levels of a store, catalog, and tenant to associate objects to a site.
masterCatalogId integer Unique identifier for the master catalog.
catalogId integer The unique identifier for the product catalog. Catalogs are part of a master catalog.
currencyCode string The default three-letter ISO currency code for monetary amounts.
previewDate date/time The date and time that the content is being viewed. This might be a future date if the content is previewed with an active date range set in the future.
localeCode string The locale code per the country code provided. This code determines the localized content to use and display.
correlationId string The unique identifier of the API request associated with the event action, which might contain multiple actions.
isAuthorizedAsAdmin Boolean Indicates whether the Dev Account user is authorized as an admin.
userClaims string The user claims token.

Example:

context.apiContext.baseUrl;




configuration
Receives a JSON response that contains information about the configuration data set in the Action Management JSON editor.
Properties Type Description
Varies object Custom fields and values that you can set in the Action Management JSON Editor.

Example:

context.configuration.customData;