Merge baskets.
Operation ID: mergeBasketMerge data from the previous shopper's basket into the current shopper's active basket and delete the previous shopper's basket. This endpoint doesn't merge Personally Identifiable Information (PII). You must obtain the shopper authorization token via SLAS and you must provide the ‘guest usid‘ in both the ‘/oauth2/login‘ and ‘/oauth2/token‘ calls while fetching the registered user JWT token. After the merge, all basket amounts are recalculated and totaled, including lookups for prices, taxes, shipping, and promotions, unless hooks are enabled.
The following information is merged:
- custom attributes on the basket and on all copied records
- product items
- gift certificate items
- coupon items
- shipments
- ad-hoc price adjustments
To control the merging of products that exist in both baskets, use the productItemMergeMode
parameter. By default, the higher of the two basket quantities is used for each product. Products in both baskets are considered to be the same when all of the following values match (if one product doesn't have a value, the other product is a match only if it also doesn't have that value):
- shipment
- productId
- option values
- wishlist reference
- inventory list id
- gift flag & message
- ad-hoc price adjustments
If any of the listed values don't match, then the item in the previous shopper's basket is copied to a new line item in the current shopper's basket. If the listed values all match, but the matching products have different values for any custom attribute, the merged line item keeps the custom attribute value from the current shopper's basket.
A success response contains the current shopper's active basket. The previous guest shopper's active basket is deleted.
If the current shopper doesn't have an active basket, and the createDestinationBasket request parameter is false, then the merge request returns a BasketMergeException (HTTP status 409). You can proceed with one of these options:
- Transfer the previous shopper's active basket to the current logged-in shopper by calling the
baskets/transfer
endpoint. - Force the merge by calling the
baskets/merge
endpoint again, with the parametercreateDestinationBasket=true
. Forcing the merge creates a new basket for the current shopper and copies information from the previous shopper's basket into it. Because the merge doesn't copy all basket data, a forced merge is not the same as a transfer. For example, the new basket doesn't contain any Personally Identifiable Information (PII) from the previous basket.
before merge
Previous Shopper's Basket, SKU: Quantity, Custom Attributes | Current Shopper's Basket, SKU: Quantity, Custom Attributes |
---|---|
SKU_A: 5 SKU_B: 3 SKU_C: 4 c_customAttr_1: 'ABC' c_customAttr_2: 'DEF' |
SKU_A: 2 SKU_D: 6 SKU_E: 7 c_customAttr_1: 'UVW' c_customAttr_3: 'XYZ' |
after merge - (previous shopper's basket is deleted)
productItemMergeMode | Current Shopper's Basket - SKU: Quantity, Custom Attributes |
---|---|
sum_quantities | SKU_A: 7 SKU_B: 3 SKU_C: 4 SKU_D: 6 SKU_E: 7 c_customAttr_1: 'UVW' c_customAttr_2: 'DEF' c_customAttr_3: 'XYZ' |
higher_quantity | SKU_A: 5 SKU_B: 3 SKU_C: 4 SKU_D: 6 SKU_E: 7 c_customAttr_1: 'UVW' c_customAttr_2: 'DEF' c_customAttr_3: 'XYZ' |
saved_quantity | SKU_A: 2 SKU_B: 3 SKU_C: 4 SKU_D: 6 SKU_E: 7 c_customAttr_1: 'UVW' c_customAttr_2: 'DEF' c_customAttr_3: 'XYZ' |
separate_item | SKU_A: 5 SKU_B: 3 SKU_C: 4 SKU_A: 2 SKU_D: 6 SKU_E: 7 c_customAttr_1: 'UVW' c_customAttr_2: 'DEF' c_customAttr_3: 'XYZ' |
curl "https://{shortCode}.api.commercecloud.salesforce.com/checkout/shopper-baskets/v2/organizations/{organizationId}/baskets/actions/merge?siteId=RefArch" \
-X POST
An identifier for the organization the request is being made by
f_ecom_zzxy_prd
The identifier of the site that a request is being made in the context of. Attributes might have site specific values, and some objects may only be assigned to specific sites
RefArch
If the current shopper has an active basket, this parameter is ignored. If the current shopper has no active basket, this parameter controls the behavior:
false
(default): Return a BasketMergeException (HTTP status 409).true
: Force the merge by creating a basket for the current shopper and copying information from the previous shopper's basket into it. Return success (HTTP status 200).
This parameter controls the quantity calculation for products that exist in both baskets.
- higher_quantity (default): Compare the product's quantities in each basket, and use the higher value.
- sum_quantities: Use the sum of the product's quantities from both baskets.
- saved_quantity: Use the product's quantity in the current shopper's active basket. Ignore the quantity from the previous shopper's basket.
- separate_item: Add a separate product item to the current shopper's basket for the quantity in the previous shopper's basket.
- higher_quantity
- sum_quantities
- saved_quantity
- separate_item
A descriptor for a geographical region by both a language and country code. By combining these two, regional differences in a language can be addressed, such as with the request header parameter Accept-Language
following RFC 2616 & RFC 1766. This can also just refer to a language code, also RFC 2616/1766 compliant, as a default if there is no specific match for a country. Finally, can also be used to define default behavior if there is no locale specified.
en-US
The current shopper's active basket, including items merged from the previous shopper's basket.
{
"adjustedMerchandizeTotalTax": 30,
"adjustedShippingTotalTax": 0.8,
"agentBasket": false,
"basketId": "a10ff320829cb0eef93ca5310a",
"billingAddress": {
"address1": "104 Presidential Way",
"city": "Woburn",
"countryCode": "US",
"firstName": "Stephanie",
"fullName": "Stephanie Miller",
"id": "bfea663fd3de75d5be3ec02702",
"lastName": "Miller",
"postalCode": "01801",
"stateCode": "MA"
},
"channelType": "storefront",
"couponItems": [
{
"code": "5ties",
"couponItemId": "cc6ef43f207bf64099288aec36",
"statusCode": "no_applicable_promotion",
"valid": true
}
],
"creationDate": "2019-10-17T08:29:55.340Z",
"currency": "USD",
"customerInfo": {
"customerId": "beQeANXJNsd0xcINsB6cSrobQa",
"email": "shopper@salesforce-test.com"
},
"lastModified": "2019-10-17T08:29:55.698Z",
"merchandizeTotalTax": 30,
"orderTotal": 646.76,
"paymentInstruments": [
{
"amount": 0,
"paymentCard": {
"cardType": "Visa",
"creditCardExpired": false
},
"paymentInstrumentId": "b7679bea661819b2de78b9de7d",
"paymentMethodId": "CREDIT_CARD"
}
],
"productItems": [
{
"adjustedTax": 30,
"basePrice": 199.99,
"bonusProductLineItem": false,
"gift": false,
"itemId": "3d4e28425ce0b3a65b0ac4e163",
"itemText": "Green Umbrella - Sustained Edition",
"optionItems": [
{
"adjustedTax": 0,
"basePrice": 0,
"bonusProductLineItem": false,
"gift": false,
"itemId": "ff9452ed11fcf5c80f9143a8f1",
"itemText": "We will plant a tree for your order.",
"optionId": "plantATree",
"optionValueId": "000",
"price": 0,
"priceAfterItemDiscount": 0,
"priceAfterOrderDiscount": 0,
"productId": "000",
"productName": "Plant a tree.",
"quantity": 3,
"shipmentId": "me",
"tax": 0,
"taxBasis": 0,
"taxClassId": "standard",
"taxRate": 0.05
}
],
"price": 599.97,
"priceAfterItemDiscount": 599.97,
"priceAfterOrderDiscount": 599.97,
"productId": "green-umbrella",
"productName": "Green Umbrella - Sustained Edition",
"quantity": 3,
"shipmentId": "me",
"tax": 30,
"taxBasis": 599.97,
"taxClassId": "standard",
"taxRate": 0.05
}
],
"productSubTotal": 599.97,
"productTotal": 599.97,
"shipments": [
{
"adjustedMerchandizeTotalTax": 30,
"adjustedShippingTotalTax": 0.8,
"gift": false,
"merchandizeTotalTax": 30,
"productSubTotal": 599.97,
"productTotal": 599.97,
"shipmentId": "me",
"shipmentTotal": 646.76,
"shippingAddress": {
"address1": "4162 Turkey Pen Road",
"city": "New York",
"countryCode": "US",
"firstName": "Agustin",
"fullName": "Agustin Estes",
"id": "4432af77112f7c2433248a48e8",
"lastName": "Estes",
"postalCode": "10016",
"stateCode": "NY"
},
"shippingMethod": {
"description": "Order received within 7-10 business days",
"id": "001",
"name": "Ground",
"price": 15.99
},
"shippingStatus": "not_shipped",
"shippingTotal": 15.99,
"shippingTotalTax": 0.8,
"taxTotal": 30.8
}
],
"shippingItems": [
{
"adjustedTax": 0.8,
"basePrice": 15.99,
"itemId": "d5ed0e58b8f8b5efe8d617a630",
"itemText": "Shipping",
"price": 15.99,
"priceAfterItemDiscount": 15.99,
"shipmentId": "me",
"tax": 0.8,
"taxBasis": 15.99,
"taxClassId": "standard",
"taxRate": 0.05
}
],
"shippingTotal": 15.99,
"shippingTotalTax": 0.8,
"taxation": "net",
"taxTotal": 30.8
}
The total tax on products in the shipment, including item-level price adjustments but not including service charges such as shipping. If the Discount Taxation preference is set to Tax Products and Shipping Only Based on Adjusted Price, this amount also includes prorated order-level price adjustments. It is read only.
4.95
The total tax on shipping charges in the shipment, including shipping price adjustments. It is read only.
0.3
Is the basket created by an agent? It is read only.
true
The unique identifier for the basket. It is read only.
e78aa5646a8efebdd9cdd38be7
The billing address.
The bonus discount line items.
The sales channel. It is read only.
- storefront
- callcenter
- marketplace
- dss
- store
- facebookads
- subscriptions
- onlinereservation
- customerservicecenter
- instagramcommerce
- tiktok
- snapchat
- youtube
storefront
The coupon items.
[{
"code": "10_percent_off"
}]
The timestamp when the basket was created. It is read only.
2015-05-19T15:23:18.000Z
A three letter uppercase currency code conforming to the ISO 4217 standard, or the string N/A
indicating that a currency is not applicable.
USD
The customer information, if the customer is logged in.
The gift certificate line items.
[{
"amount": 1,
"recipientEmail": "miller@salesforce-test.com",
"shipmentId": "me"
}]
Tax values that are grouped and summed based on the tax rate. The tax totals of the line items with the same tax rate are grouped together and summed up. This does not affect the calculation in any way. It is read only.
The expiration datetime of the inventory reservation. It is read only.
2015-05-19T15:30:18.000Z
The timestamp when the basket was last modified. It is read only.
2015-05-19T15:25:18.000Z
The total products tax in the purchase currency. Merchandise total price represents the sum of the product prices before services (such as shipping) or adjustments from promotions have been added. It is read only.
4.95
The order-level price adjustments.
[{
"appliedDiscount": {
"amount": 15,
"type": "amount"
},
"itemText": "AgentOrderAdjustment",
"reasonCode": "override manual promo"
}]
The total price, including products, shipping and tax. It is read only.
110.24
The payment instruments list.
[{
"amount": 0,
"paymentCard": {
"holder": "Miller",
"cardType": "Visa"
},
"paymentMethodId": "CREDIT_CARD"
}]
The product items.
[{
"quantity": 1
}]
The total price of all products including item-level adjustments, but not including order-level adjustments or shipping charges. If the taxation policy is net, it doesn't include tax. If the taxation policy is gross, it includes tax. It is read only.
99
The total price of all products including adjustments, but not including shipping charges. If the taxation policy is net, it doesn't include tax. If the taxation policy is gross, it includes tax. It is read only.
88
The shipments.
[{
"shipmentId": "me2",
"shippingMethod": {
"id": "001"
},
"shippingAddress": {
"firstName": "Stephanie",
"lastName": "Miller",
"address1": "385 Prospect Valley Road",
"city": "Woburn",
"postalCode": "01801",
"stateCode": "MA",
"countryCode": "US"
}
}]
The shipping items.
The total price of all shipping charges, including shipping adjustments. If the taxation policy is net, it doesn't include tax. If the taxation policy is gross, it includes tax. It is read only.
5.99
The total tax on all shipping charges, not including shipping adjustments. It is read only.
0.3
The source code assigned to the basket. It is read only.
OUTDOOR1
The total tax amount. It is read only.
5.25
The taxation policy (gross or net). It is read only.
- gross
- net
net
If the tax is rounded at the group level, this is set to true. If the tax is rounded at the item or unit level, it is set to false.
true
If the created basket is a temporary basket, this is set to true. Otherwise, it is set to false.
true
This type supports additional properties passed along with the defined properties of this API.
To indicate that the properties were defined and expected to be handled as additional properties, they are expected to be prefixed with a c_
.
The type will reject any property that does not fit this pattern, only allowing additional properties beginning with the known prefix.