Skip to content

Conversation

Tharaae
Copy link
Contributor

@Tharaae Tharaae commented Sep 22, 2025

What/Why?

As part of backorders project, we want to give the merchant an option to display a backorders prompt to the shopper on the product details page for products that have backordering available. This need to be built on the stock level message feature (as in cornerstone) that is not implemented as a catalyst default feature.

This PR is to implement the stock level message on the product details page based on the store inventory settings.

Testing

Screenshots

When the product is in stock and "Show stock levels" is selected:
Screenshot 2025-09-22 at 12 05 04 pm
Screenshot 2025-09-22 at 12 10 39 pm
Screenshot 2025-09-22 at 12 10 01 pm

When the product is in stock and "Don's show stock levels" is selected:
Screenshot 2025-09-22 at 12 05 04 pm
Screenshot 2025-09-22 at 12 12 41 pm
Screenshot 2025-09-22 at 12 13 24 pm

When the product is in stock but below or equal warning level and "Only show stock levels when stock is low" is selected:
Screenshot 2025-09-22 at 10 28 01 am
Screenshot 2025-09-22 at 10 29 04 am
Screenshot 2025-09-22 at 10 29 43 am

When the product is in stock and above warning level and "Only show stock levels when stock is low" is selected:
Screenshot 2025-09-22 at 12 05 04 pm
Screenshot 2025-09-22 at 10 29 04 am
Screenshot 2025-09-22 at 12 04 38 pm

When the product is not in stock and "Out of stock message" is set:
Screenshot 2025-09-22 at 12 16 57 pm
Screenshot 2025-09-22 at 12 14 49 pm
Screenshot 2025-09-22 at 12 16 35 pm

Migration

None

@Tharaae Tharaae requested a review from a team as a code owner September 22, 2025 03:31
Copy link

changeset-bot bot commented Sep 22, 2025

🦋 Changeset detected

Latest commit: 0e66b8f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@bigcommerce/catalyst-core Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Sep 22, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
catalyst-b2b Ready Ready Preview Comment Sep 26, 2025 5:30am
catalyst-canary Ready Ready Preview Comment Sep 26, 2025 5:30am
3 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
catalyst Ignored Ignored Sep 26, 2025 5:30am
catalyst-au Ignored Ignored Sep 26, 2025 5:30am
catalyst-uk Ignored Ignored Sep 26, 2025 5:30am

}

if (
stockLevelDisplay === 'DONT_SHOW' ||

Choose a reason for hiding this comment

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

Can we type 'DONT_SHOW' and other values in an enum?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The type of stockLevelDisplay is already defined by bigcommerce graphql data types as a set of values. This is common for graphql fields in Catalyst.
Screenshot 2025-09-23 at 7 01 03 am

return null;
}

return t('ProductDetails.currentStock', {

Choose a reason for hiding this comment

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

What is t here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's defined on this line where translations related to "Product" page are fetched.


if (
stockLevelDisplay === 'DONT_SHOW' ||
(stockLevelDisplay === 'SHOW_WHEN_LOW' &&

Choose a reason for hiding this comment

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

This condition feels a bit overloaded and hard to read. Can this be simplified? Maybe we can use a util method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll decompose it to be more clear like:

    if (stockLevelDisplay === 'DONT_SHOW') {
      return null;
    }

    if (stockLevelDisplay === 'SHOW_WHEN_LOW') {
      const { availableToSell, warningLevel } = product.inventory.aggregated ?? {};

      if (!warningLevel) {
        return null;
      }

      if (availableToSell && availableToSell > warningLevel) {
        return null;
      }
    }

@bc-apostoliuk
Copy link

LGTM

Copy link
Contributor

@chanceaclark chanceaclark left a comment

Choose a reason for hiding this comment

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

Thanks @Tharaae for this! Small change, otherwise looks good on our end!

Comment on lines 124 to 126
{Boolean(product.stockLevelMessage) && (
<p className="prose prose-sm">{product.stockLevelMessage}</p>
)}
Copy link
Contributor

Choose a reason for hiding this comment

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

Since you are a Streamable, we should wrap it in a <Stream> component to actually stream this data in on page load otherwise it'll be a blocking request. Additionally, we should be using the CSS variables for the stylings here so we get the benefit of Makeswift theming.

Suggested change
{Boolean(product.stockLevelMessage) && (
<p className="prose prose-sm">{product.stockLevelMessage}</p>
)}
<Stream fallback={<ProductStockSkeleton />} value={product.stockLevelMessage}>
{(stockLevelMessage) =>
Boolean(stockLevelMessage) && (
<p className="text-[var(--product-detail-secondary-text,hsl(var(--contrast-500)))]">
{stockLevelMessage}
</p>
)
}
</Stream>

Copy link
Contributor

@chanceaclark chanceaclark left a comment

Choose a reason for hiding this comment

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

Thanks so much for adding this! I'm going to approve this, but one last thing before you merge, can you add a changeset to this PR? All you need to run is pnpm changeset from the root folder and it'll walk you through some questions. Space to select, enter to continue – you'll press enter on the first question in order to get to the next (you'll see what I mean 😅).

@Tharaae Tharaae added this pull request to the merge queue Sep 29, 2025
Merged via the queue into canary with commit 19077cd Sep 29, 2025
11 checks passed
@Tharaae Tharaae deleted the BACK-348 branch September 29, 2025 00:30
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.

4 participants