Skip to content

@W-19347602 - Fix In Store Inventory Stock Level Checks - #3401

Merged
shauryemahajanSF merged 8 commits into
developfrom
t/commerce/W-19347602/fixInStoreStockLevels
Oct 16, 2025
Merged

@W-19347602 - Fix In Store Inventory Stock Level Checks#3401
shauryemahajanSF merged 8 commits into
developfrom
t/commerce/W-19347602/fixInStoreStockLevels

Conversation

@shauryemahajanSF

@shauryemahajanSF shauryemahajanSF commented Oct 15, 2025

Copy link
Copy Markdown
Contributor

Description

Right now, on the product view on cart and PLP, when selecting inventory of pick up item, we get notified about stock levels of delivery instead. This PR fixes this issue so inventory messages take into account the in store inventory instead.

Note,the behavior of being able to select (but not save) a value greater than the stock level on cart exists (This predates bopis).

Before (both use same delivery stock levels):

Screen.Recording.2025-10-15.at.6.05.00.PM.mov

After:

Screen.Recording.2025-10-15.at.5.52.35.PM.mov

Types of Changes

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Breaking change (could cause existing functionality to not work as expected)
  • Other changes (non-breaking changes that does not fit any of the above)

Breaking changes include:

  • Removing a public function or component or prop
  • Adding a required argument to a function
  • Changing the data type of a function parameter or return value
  • Adding a new peer dependency to package.json

Changes

  • Change useDerivedHook to account for pick up selection

How to Test-Drive This PR

  • Add an item for pick up and see on PDP and cart that the 'Only x left!' message has the correct inventory now and uses in store inventory.

Checklists

General

  • Changes are covered by test cases
  • CHANGELOG.md updated with a short description of changes (not required for documentation updates)

Accessibility Compliance

You must check off all items in one of the follow two lists:

  • There are no changes to UI

or...

Localization

  • Changes include a UI text update in the Retail React App (which requires translation)

@cc-prodsec

cc-prodsec commented Oct 15, 2025

Copy link
Copy Markdown
Collaborator

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Licenses 0 0 0 0 0 issues
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@shauryemahajanSF
shauryemahajanSF marked this pull request as ready for review October 16, 2025 13:12
@shauryemahajanSF
shauryemahajanSF requested a review from a team as a code owner October 16, 2025 13:12

// Product details for selected store
const selectedStoreInventory = getInventoryById(product, selectedStore?.inventoryId)
const selectedStoreStockLevel = selectedStoreInventory?.stockLevel || 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

selectedStoreInventory is undefined, the result is "stock level 0," making the product appear out of stock, but is it possible that the inventory was just not yet loaded/ partial data was retrieved from api

@sf-henry-semaganda sf-henry-semaganda left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@patricksullivansf patricksullivansf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you

const isSelectedStoreOutOfStock = !selectedStoreStockLevel || !selectedStoreInventory?.orderable
const selectedStoreUnfulfillable = selectedStoreStockLevel < quantity

// Use appropriate inventory based on pickup/delivery selection

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to mention here that if compatibility with v8.1 or earlier API is needed use pickupInStore false

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, added note

@gurpreetsainisalesforce gurpreetsainisalesforce left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@shauryemahajanSF
shauryemahajanSF enabled auto-merge (squash) October 16, 2025 21:21
@shauryemahajanSF
shauryemahajanSF merged commit 1adfe9f into develop Oct 16, 2025
42 checks passed
@shauryemahajanSF
shauryemahajanSF deleted the t/commerce/W-19347602/fixInStoreStockLevels branch October 16, 2025 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants