Shein Adds 15 Million New European Users, Extends Lead Over Temu
Chinese fast-fashion giant Shein has gained over 15.2 million new monthly users in Europe between
When you go to purchase something from a store and they have no stock, it’s so disappointing. Knowing the product is not available and when it will be restocked makes things easier for the shopper. So here we have come up with a blog that will show you how to add stock status on the product page in Magento 2 PWA Studio. This will allow your customers to see stock availability messages on the product page.
Check out our Cenia Pro Theme for Magento 2 PWA, works fast and seamlessly.
Being the fourth blog in the series dedicated to Magento PWA Studio, you can check out our other publications related to PWA studio learnings-
By learning how to add stock status on the product page in Magento 2 PWA Studio you can assign statuses like in stock and out of stock for an inventory situation and products can be aligned either automatically or manually. This will help to keep your customers informed with precise information about stock availability.
First, you need to create a Venia project through scaffolding
https://magento.github.io/pwa-studio/pwa-buildpack/scaffolding/
yarn create @magento/pwa
Once you have your scaffolded Venia project Then go inside your project directory
Then we need to add our custom component for stock status in the Product Detail component
Click to check us out on GitHub
For this we need to add our code in local-intercept.js [YOUR_PROJECT_NAME/local-intercept.js]
function localIntercept(targets) { const { Targetables } = require('@magento/pwa-buildpack'); const targetables = Targetables.using(targets); // Create a targetable component linked to the productFullDetail.js file const ProductDetailsComponent = targetables.reactComponent( '@magento/venia-ui/lib/components/ProductFullDetail/productFullDetail.js' ); // Add an import statement to the productFullDetail.js file and const StockStatus = ProductDetailsComponent.addImport( "ProductStockStatus from '/src/components/ProductStockStatus'" ); // Insert the StockStatus component after the product name ProductDetailsComponent.insertAfterJSX( '<h1 className={classes.productName}>', `<${StockStatus} productSku={productDetails.sku} />` ); } module.exports = localIntercept;
We then need to add our component inside the src directory
Interesting reads: Why should you choose PWA Magento for eCommerce website?
index.js [YOUR_PROJECT_NAME/src/components/ProductStockStatus/index.js]
export { default } from './stockStatus.js';
stockStatus.js [YOUR_PROJECT_NAME/src/components/ProductStockStatus/stockStatus.js]
import React from 'react'; import useProductStockStatus from '../../peregrine/lib/talons/ProductStockStatus/useProductStockStatus.js'; const productStockstatus = props => { const {productSku} = props; const {stockStatus} = useProductStockStatus({ sku: productSku, }); return ( <> {stockStatus && <p>{stockStatus.replace(/_/g,' ')}</p>} </> ); }; export default productStockstatus;
Now add talon to get product stock status
Avail of our Cenia Pro theme user guide
useProductStockStatus.js [YOUR_PROJECT_NAME/src/peregrine/lib/talons/ProductStockStatus/useProductStockStatus.js
import { useMemo } from "react"; import { useQuery } from "@apollo/client"; import GET_PRODUCT_STOCK_STATUS from './productStockStatus.gql.js'; const useProductStockStatus = (props) => { const { sku } = props; const { error, loading, data } = useQuery(GET_PRODUCT_STOCK_STATUS, { fetchPolicy: "cache-and-network", nextFetchPolicy: "cache-first", variables: { sku: sku } }); const stockStatus = useMemo(() => { if (data && data.products.items[0]) { return data.products.items[0].stock_status; } return null; }, [data]); return { error, isLoading: loading, stockStatus }; }; export default useProductStockStatus;
productStockStatus.gql.js [YOUR_PROJECT_NAME/src/peregrine/lib/talons/ProductStockStatus/productStockStatus.gql.js]
import gql from "graphql-tag"; const GET_PRODUCT_STOCK_STATUS = gql` query getProductStockStatus($sku: String!) { products(filter: { sku: { eq: $sku } }) { items { stock_status } } } `; export default GET_PRODUCT_STOCK_STATUS;
After that run your project
yarn build
yarn start
This is what your end result should look like
This is the procedure that you can follow to add stock status on the product page in Magento 2 PWA Studio. We hope we were able to share it in a simple way and would encourage you to give it a try.
Check out our Magento 2 PWA Theme For ECommerce- an app-like experience at a fraction of the cost
You can expect similar articles as we want to share what we have learned, things that have made Cedcommerce what we are today.
Contact us for any related queries and we will be happy to help!
Chinese fast-fashion giant Shein has gained over 15.2 million new monthly users in Europe between
Alibaba.com, the global B2B marketplace of Chinese eCommerce giant Alibaba Group, has announced a strategic
TikTok Shop has released updated Affiliate Marketing (Seller & Product Qualification) Guidelines. These changes are
If you’re wondering how to sell Etsy products on TikTok, the answer starts with treating
Amazon has sparked widespread alarm among electronics sellers across Europe after announcing new requirements that
Summary Pattern Group, one of the largest Amazon resellers and an e-commerce accelerator, has filed
Summary U.S. eCommerce spending grew 8% year over year in August, up from 7% in
Summary The EU’s Data Act (Regulation (EU) 2023/2854) is now legally effective as of 12
In a move that signals a major shift in the advertising world, Amazon Ads and
Mars Petcare UK has officially joined Temu, the fast-rising online marketplace that’s been disrupting global
In 2024, out-of-stock rates surged to 39% for high-demand SKUs by Day 2 of Cyber
News Summary Amazon has officially launched Virtual Multipacks (VMPs), a long-requested feature allowing sellers to
Temu, the fast-rising discount eCommerce marketplace owned by PDD Holdings, continues its rapid expansion in
The upcoming holiday shopping season is projected to deliver steady gains for U.S. retailers, though
Amazon is officially shutting down its long-running Prime Invitee program, a little-known but popular perk
Critical security alert for Adobe Commerce & Magento merchants. Adobe has issued an out-of-band emergency
Exciting news for WooCommerce sellers! WooCommerce 10.2 is officially launching on September 16, 2025, introducing
Effective: September 30, 2025 (U.S. & Canada) Amazon is overhauling its inventory recovery programs. Starting
TikTok has rolled out a set of new support tools for TikTok Shop creators, aiming
Amazon has launched FBA Damaged Inventory Ownership, a program that lets sellers take direct control