#
Service URL: POST /baskets/{basketReference}/items
Tokens:
basketReference – The basket reference of the basket to add the item to, or can be ‘PRIMARY’ to add to the PRIMARY basket.
Request Parameters:
returnBasket – Boolean – If true the updated basket is returned – Defaults to false
Request Body:
IAddBasketItemRequest:
itemType – String – The type of the item to add to the basket. Currently, supported types are VOUCHER, PRODUCT and OPTION_PRODUCT. Optional, defaults to PRODUCT.
itemId – String – The id of the item to add to the basket. If the type is PRODUCT or empty, the item should be the id of the product. When the type is VOUCHER, the item id should be the vouchers serial number – Required
quantity – Integer – The quantity to add to the basket – Optional, defaults to 1
itemUnitPrice – Long – The unit price for this item – Optional, defaults to the “standard” price for this product
optionSets – OptionSetDetails – If adding an item using the OPTION_PRODUCT itemType, this property will be used to specify the details of the options. This property is not supported for other values of itemType.
Response Headers:
Location: /baskets/{basketReference}/items/{lineNumber}
Response Body:
IBasketItemResponse:
basketItemLineNumber – String – the line number of the item added to the basket.
basket – IBasket – The new or updated transaction containing the item being added, if returnBasket is true
basketReference – String – the reference of the basket
basketType – String – the type of the basket
basketDescription – String – the description of the basket
basketResponseCode – String – A specific basket code to indict whether the basket was implicitly created by the server.
basketStatus – String – the status of the basket. Fresh baskets have the status NEW. Baskets in progress have the status of IN_PROGRESS. Baskets will have been submitted to retail processing have the status SUBMITTED.
Remarks:
Adds a new item to a basket. If the PRIMARY basket is specified and it does not currently exist, it will be created. However, if a wishlist basket that does not exists, the service call should fail with a bad request. The lineNumber for the new item is returned in the response header. If the returnBasket
the parameter is true, the updated basket and the line number of the new item is returned in the response body.
The itemUnitPrice can be used to override the standard Enactor price lookup – if this field is not supplied, Enactor will search for and load a price in the standard manner.
Option Products
When you are adding an option product to the basket you can additionally configure the options associated with the product. This is done using the optionSets property. The property accepts a collection of option sets and the values to use for the options in that option set, for example:Show option set example
|
Here we are specifying the optionSet key (myoptionset) along with its associated region. We are then specfying that in this option set, we want to set the value of the MyProductOption option to PRODUCT_1. As this is a product option, we can also specify the quantity and unit price for the product to be sold as an option.
Currently only PRODUCT_OPTION options can be added through the Rest API. It is also not possible to currently add “recursive” options (i.e. options that have their own options).
Scenarios:
Primary Basket Scenarios
All scenarios start with “Basket items service has received a request to add an item to a primary basket”.
Scenario | Outcome | Expected behavior | Status Code | Response | |
---|---|---|---|---|---|
1 | The customer does not currently have a primary basket. Return basket is empty | success | A new primary basket gets created with the item. The basket is not returned | 200 | 200 Success ok |
2 | The customer does not currently have a primary basket. Return basket is set to true | success | A new primary basket gets created with the item. The basket is returned | 200 | IBasketResponse: basket |
3 | The customer already has a primary basket. Return basket is empty | success | The item should be added to the existing basket. The basket is returned | 200 | 200 Success ok |
4 | The customer already has a primary basket. Return basket is set to true | success | The item should be added to the existing basket. The basket is not returned | 200 | IBasketResponse: basket |
Wishlist Basket Scenarios
All scenarios start with “Basket items service has received a request to add the item to a wishlist basket”.
Scenario | Outcome | Expected behavior | Status Code | Response | |
---|---|---|---|---|---|
1 | The wishlist basket exists, and return basket is empty | success | The item should be added to the existing wishlist basket. The basket is not returned | 200 | 200 Success ok |
2 | The wishlist basket exists, and return basket is set to true | success | The item should be added to the existing wishlist basket. The basket is returned | 200 | IBasketResponse: basket |
3 | The wishlist basket does not exist | BadRequest | The service should return and an error message stating that it can’t add the item to the specified basket. | 400 | Error Message: Failed to add the item to the basket. Bad Request |
Example Request:
Response Body:
Status: 200 OK
{
"basketItemLineNumber": "3",
"basketType": "PRIMARY",
"basketDescription": "Primary",
"basket": {
"items": [
{
"@type": "orderDetailsItem",
"description": "Order",
"deviceId": "pos2@0001.enactor",
"effectiveNetValue": -9955,
"lineNumber": 1,
"netValue": -9955,
"value": -9955,
"dateTimeCreated": "2019-08-22T15:01:07.000+01:00",
"userId": "CUST_USER",
"type": "VALUE",
"orderReference": "149",
"sendCustomerDeliveryNotification": true,
"customerOrderTypeId": "CUSTOMER_ORDER"
},
{
"@type": "styleColourSizeItem",
"colourId": {
"id": "RED",
"colourRangeId": "MENS_SHOES"
},
"description": "Vans Canvas Shoes",
"deviceId": "pos2@0001.enactor",
"effectiveNetValue": 5995,
"lineNumber": 2,
"netValue": 5995,
"value": 5995,
"dateTimeCreated": "2019-08-22T15:01:18.000+01:00",
"userId": "CUST_USER",
"modifiersNetValue": 0,
"modifiersEffectiveNetValue": 0,
"modifiersVoidQuantity": 0,
"modifiersQuantity": 0,
"notDiscountable": false,
"maxDiscount": 0,
"handKeyed": true,
"productID": "VV639JS-12",
"quantity": 1,
"netQuantity": 1,
"isReturn": false,
"unitPrice": 5995,
"sourceInventoryType": "AVA",
"orderable": true,
"priceTypeId": "R",
"productTypeId": "skuProduct",
"productImageURL": "image://PRODUCT/VV639JS-1.jpg",
"type": "VALUE",
"mmGroupId": "MENS_SHOES",
"mmGroupHierarchyId": "FASHION",
"mmGroupVariantGroupId": "All",
"mmGroupVariantHierarchyId": "All",
"mmGroupDescription": "Mens Shoes",
"brandGroupId": "VANS",
"brandGroupHierarchyId": "FASHION",
"modifiers": [
{
"@type": "orderModifier",
"modifierItemLine": 1
}
],
"sizeId": {
"id": "12",
"sizeRangeId": "MENS_SHOES"
}
},
{
"@type": "styleColourSizeItem",
"colourId": {
"id": "NAVY_BLUE",
"colourRangeId": "WOMENS_DRESSES"
},
"description": "Rose Print Tea Dress",
"deviceId": "pos2@0001.enactor",
"effectiveNetValue": 3960,
"lineNumber": 3,
"netValue": 4260,
"value": 4260,
"dateTimeCreated": "2019-08-29T12:19:35.000+01:00",
"userId": "CUST_USER",
"modifiersNetValue": 0,
"modifiersEffectiveNetValue": -300,
"modifiersVoidQuantity": 0,
"modifiersQuantity": 0,
"notDiscountable": false,
"maxDiscount": 0,
"handKeyed": true,
"productID": "MB709SN-4",
"quantity": 1,
"netQuantity": 1,
"isReturn": false,
"unitPrice": 4260,
"sourceInventoryType": "AVA",
"orderable": true,
"priceTypeId": "R",
"productTypeId": "skuProduct",
"productImageURL": "image://PRODUCT/MB709SN-2.jpg",
"type": "VALUE",
"mmGroupId": "WOMENS_DRESSES",
"mmGroupHierarchyId": "FASHION",
"mmGroupVariantGroupId": "All",
"mmGroupVariantHierarchyId": "All",
"mmGroupDescription": "Women's Dresses",
"brandGroupId": "INTERNAL",
"brandGroupHierarchyId": "FASHION",
"modifiers": [
{
"@type": "orderModifier",
"modifierItemLine": 1
},
{
"@type": "distributedPromotionSavingItem",
"lineNumber": 3,
"distributedSaving": 300,
"promotionKey": {
"promotionId": "AmountDiscount",
"groupKey": {
"id": "UK",
"groupTypeId": "region",
"groupHierarchyId": "All"
}
},
"modifierType": "PROMOTION",
"modifierItemLine": 0,
"effectiveValue": -300
}
],
"sizeId": {
"id": "14",
"sizeRangeId": "WOMENS_DRESSES"
}
}
],
"balance": 0,
"currencyId": "GBP",
"currencyDescription": "Pounds Sterling",
"taxInclusive": true,
"taxSchemeId": "UK",
"itemCount": 3,
"saleItemQuantity": 2,
"returnItemQuantity": 0,
"saleItemNetValue": 9955,
"returnItemNetValue": 0,
"merchandiseItemQuantity": 2,
"merchandiseItemValue": 10255,
"total": 0,
"grossTotal": 300,
"taxTotal": 0,
"promotionCalculation": {
"totalSaving": 300,
"totalPoints": 0,
"itemsArray": [
{
"promotionSavingItem": {
"saving": 300,
"savingAdjustment": 0,
"adjustEmployeeBalance": false,
"promotionDescription": "£3 off of KAT VON D Eye Liner",
"promotionQuantity": 1,
"operationWithDiscounts": "APPLIES_AFTER_ON_GROSS",
"promotionKey": {
"promotionId": "AmountDiscount",
"groupKey": {
"id": "UK",
"groupTypeId": "region",
"groupHierarchyId": "All"
}
},
"triggers": [
{
"rewardValue": 300,
"lineRewardValue": 300,
"distributeSaving": true,
"lineNumber": 3,
"quantity": 1,
"unitValue": 4260,
"triggerCount": 1,
"rewardId": "1"
}
]
}
}
]
},
"currentModifierLineNumber": 1,
"totalTaxAdjustment": 0,
"preAuthBalance": 0,
"effectiveSaleValue": 9955
},
"basketResponseCode": "BASKET_ITEM_ADDED"
}
|