Closed
Description
Step 3: Describe the problem:
In the current implementation of productdisplayitem.main.tsx, if a user has more than just the default cart, adding an item with Cart Item Modifiers to your cart will fail. This is caused by using the selected carts additemstocart
resource which does not support Cart Item Modifiers, as opposed to the items addtocartforms
resource which does.
Steps to reproduce:
- Log in as an Authenticated User
- Create a second cart
- Try to add a product with Cart Item Modifiers to the cart
Observed Results:
We get the message Item '' is a configurable product. Please add it individually using 'additemtocart' form.
Expected Results:
That it gets added to the cart with the appropriate Cart Item Modifier values
Relevant Code:
The function that calls the additemstocart resource.
addToSelectedCart(cart, onCountChange) {
const cartUrl = cart._additemstocartform[0].self.uri;
const { itemQuantity, productData } = this.state;
this.setState({ addToCartLoading: true });
login().then(() => {
const body: { [key: string]: any } = {};
body.items = { code: productData._code[0].code, quantity: itemQuantity };
cortexFetch(cartUrl,
{
method: 'post',
headers: {
'Content-Type': 'application/json',
Authorization: localStorage.getItem(`${Config.cortexApi.scope}_oAuthToken`),
},
body: JSON.stringify(body),
})
.then((res) => {
if (res.status === 200 || res.status === 201) {
this.setState({ addToCartLoading: false });
const cartName = cart._descriptor[0].name ? cart._descriptor[0].name : intl.get('default');
onCountChange(cartName, itemQuantity);
}
})
.catch((error) => {
// eslint-disable-next-line no-console
console.error(error.message);
this.setState({ addToCartLoading: false });
});
});
}
Metadata
Metadata
Assignees
Labels
No labels