SAP / spartacus

Spartacus is a lean, Angular-based JavaScript storefront for SAP Commerce Cloud that communicates exclusively through the Commerce REST API.
Apache License 2.0
744 stars 389 forks source link

Multi cart entries of the same product: missing 1 entry #5747

Closed tramtranthingoc closed 4 years ago

tramtranthingoc commented 4 years ago

Environment Details

SAP commerce cloud version: 1905.7 Spartacus: 1.3 Browser: any OS: any Device: any

Steps to Reproduce

  1. Configure promotion buy X get free gift (as video). In this video, we configure buy https://spartacus.c39j2-walkersde1-d4-public.model-t.cc.commerce.ondemand.com/electronics-spa/en/USD/Open-Catalogue/Cameras/DigitalCameras/Digital-SLR/DSLR-A330-%252BDT-18---55-mm/p/2934302 get free gift https://spartacus.c39j2-walkersde1-d4-public.model-t.cc.commerce.ondemand.com/electronics-spa/en/USD/product/EF-S%2060mm%20f%2F2.8%20USM%20Macro/832382 (using free gift action)
  2. Go to storefront and add 2934302 to cart. 2934302 is added to cart along with free gift 832382 .
  3. Go to PDP of 832382 and add this product to cart.

Observed Results

  1. In backoffice there are 2 cart entries:
    • 2934302, quantity 1
    • 832382, quantity 1, giveaway = true, price = $0
    • 832382, quantity 1, giveaway = true, price = $466.88
  2. Accelerator cart: 3 cart entries are displaying correctly
  3. Spartacus cart: only 1 line of 832382 is displayed.

Expected Results

Spartacus cart should display all cart entries correctly regardless there are multi cart entries per same product.

More information can be found in these videos: Accelerator: https://drive.google.com/file/d/1Q3GkpZQZVpfdLCy1Zkv7pW8ndt_yMkbE/view Spartacus (same cart): https://drive.google.com/file/d/15S8Z_gS3Bkc00HCl6km1EHy8eCUnaYwE/view

image image

marlass commented 4 years ago

It should now work correctly. All entries should be visible even if some of them have the same product code.

tramtranthingoc commented 4 years ago

@marlass you brighten up my day!

@QA: Some scenarios worth testing would be as follows: Call Camera 2934302 as X, lenses 832382 as Y.

  1. Scenario 1

    • Add X (Y should be auto added by free gift action)
    • Add another Y (as normal price)
  2. Scenario 2

    • Add X (Y should be auto added by free gift action)
    • Add another Y (as normal price)
    • Refresh the page
  3. Scenario 3

    • Add another Y (as normal price)
    • Add X (Y should be auto added by free gift action)
  4. Scenario 4

    • Add X (Y should be auto added by free gift action)
    • Add another Y (as normal price)
    • Remove Y (which has normal price)
  5. Scenario 5

    • Add X (Y should be auto added by free gift action)
    • Add another Y (as normal price)
    • Go to PDP of Y and add another to cart (should increase quantity of Y and X in cart to 2 - noted that promotion should configure with maxAllowedRuns >= 2 & with a qualified product containers in free gift action)
  6. Scenario 6

    • Add X (Y should be auto added by free gift action)
    • Add another Y (as normal price)
    • Remove X (Free gift Y should be removed along with X)
  7. Scenario 7

    • Add X (Y should be auto added by free gift action)
    • Add another Y (with a percentage discount 20% - the promotion should have priority lower than free gift promotion)
  8. Scenario 8

    • Configure stock of Y = 1
    • Add X (Y should be auto added by free gift action)
    • Add another Y
  9. Scenario 9

    • Configure stock of Y = 2
    • Add X (Y should be auto added by free gift action - noted that promotion should configure with maxAllowedRuns >= 3 & with a qualified product containers in free gift action)
    • Add another Y (cart now should have 1 X, 1 fee Y and 1 Y)
    • Increase quantity of X to 2.
  10. Repeat same scenarios 1-> 9 but add Y as normal price first then add X later.

tramtranthingoc commented 4 years ago

@marlass: we are now on SAP Commerce 1905.7. May I check with you when this fix is released, do we need to upgrade SAP commerce from 1905.7 to 1905.8 which has just been released on 10th Dec 2019?

Thanks, Tram

marlass commented 4 years ago

Hey. That has nothing to do with backend changes. We just handle cart entries differently in Spartacus now. We now show everything that backend returns us and previously there was an entry extraction mechanism that was based on product code. That was the reason only one of the entries with the same product code was visible. Try to upgrade to @spartacus/core@next and @spartacus/storefront@next versions. Warning: CartService was changed. If you extended it or provided your own look at new implementation to see what services you need to provide or if you could drop your own implementation.