Broadleaf Microservices
  • v1.0.0-latest-prod

CSR Operations

The following operations are used by CSR related functionality to perform various actions such as price match.

Cancel a CSR cart

Operation

CSRClient#cancelCSRCart(cartId, options);

Parameters

Parameter Type Required? Description

cartId

string

✅

The id of the cart.

options

CartClientCallOptions

❌

Options passed to the HTTP request call to customize the request configuration.

Response

This function returns a Cart.

Example

Example of cancelling a CSR controlled cart
const cart = await csrClient.cancelCSRCart('CART_ID', { accessToken });

console.log(cart);

Override an item’s price

Operation

CSRClient#overrideItemPriceInCart(cartId, cartItemId, overridePrice, options);

Parameters

Parameter Type Required? Description

cartId

string

✅

The id of the cart.

cartItemId

string

✅

The id of the cart item.

overridePrice

OverridePriceRequest

✅

The override price details.

options

PriceableCartClientCallOptions

❌

Options passed to the HTTP request call to customize the request configuration.

Response

This function returns a Cart.

Example of overriding a cart item’s price

const cart = await client.overrideItemPriceInCart('CART_ID', 'CART_ITEM_ID', {
  overridePrice: {
    amount: 10,
    currency: 'USD'
  },
  reason: 'Price Match'
},
{ accessToken });

console.log(cart);

Override a fulfillment group’s price

Operation

CSRClient#overrideFulfillmentGroupPriceInCart(cartId, referenceNumber, overridePrice, options);

Parameters

Parameter Type Required? Description

cartId

string

✅

The id of the cart.

referenceNumber

string

✅

The reference number of the fulfillment group.

overridePrice

OverridePriceRequest

✅

The override price details.

options

PriceableCartClientCallOptions

❌

Options passed to the HTTP request call to customize the request configuration.

Response

This function returns a Cart.

Example overriding a fulfillment group’s price

const cart = await client.overrideFulfillmentGroupPriceInCart('CART_ID', 'REF_NUMBER', {
  overridePrice: {
    amount: 0,
    currency: 'USD'
  },
  reason: 'Free Shipping'
},
{ accessToken });

console.log(cart);

Create a transfer token

Operation

CSRClient#createTransferToken(cartId, options);

Parameters

Parameter Type Required? Description

cartId

string

✅

The id of the cart.

options

CartClientCallOptions

❌

Options passed to the HTTP request call to customize the request configuration.

Response

This function returns a TransferCartToken.

Example of creating a transfer token for a cart

const token = await client.createTransferToken('CART_ID', { accessToken });

console.log(token);

Transfer anonymous cart to customer

Operation

CSRClient#consumeTransferToken(cartId, token, options);

Parameters

Parameter Type Required? Description

cartId

string

✅

The id of the cart.

token

string

✅

The transfer token to consume.

options

ClientCallOptions

❌

Options passed to the HTTP request call to customize the request configuration.

Response

This function returns a Cart.

Example of consuming a transfer token for a cart

const cart = await client.consumeTransferToken('CART_ID', 'TOKEN', { accessToken });

console.log(cart);

Clone a customer’s in-process cart

Operation

CSRClient#cloneCSRCartFromCustomer(cartId, options);

Parameters

Parameter Type Required? Description

cartId

string

✅

The id of the cart.

options

ClientCallOptions

❌

Options passed to the HTTP request call to customize the request configuration.

Response

This function returns a Cart.

Example of cloning a customer’s in-process cart

const cart = await client.cloneCSRCartFromCustomer('CART_ID', { accessToken });

console.log(cart);

Transfer cart to a customer

Operation

CSRClient#transferCSRCartToCustomer(cartId, options);

Parameters

Parameter Type Required? Description

cartId

string

✅

The id of the cart.

options

ClientCallOptions

❌

Options passed to the HTTP request call to customize the request configuration.

Response

This function returns a Cart.

Example of transferring a CSR cart to a customer

const cart = await client.transferCSRCartToCustomer('CART_ID', { accessToken });

console.log(cart);