Skip to content

Commit 226c908

Browse files
authored
Merge pull request #994 from w3bdesign/develop
Stock status
2 parents c4e1fad + ff2f0ec commit 226c908

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ The current release has been tested and is confirmed working with the following
7575

7676
## Features
7777

78-
- Next.js version 13.0.3
78+
- Next.js version 13.1.6
7979
- React 18
8080
- Connect to Woocommerce GraphQL API and list name, price and display image for products
8181
- Support for simple products and variable products
@@ -90,6 +90,7 @@ The current release has been tested and is confirmed working with the following
9090
- Shows page load progress with Nprogress during navigation
9191
- Fully responsive design
9292
- Category and product listings
93+
- Show stock status
9394
- Pretty URLs with builtin Nextjs functionality
9495
- Tailwind 3 for styling
9596
- JSDoc comments

components/Product/SingleProduct.component.jsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,24 +91,32 @@ const SingleProduct = ({ product }) => {
9191
<p className="pt-1 mt-4 text-2xl text-gray-900">
9292
{DESCRIPTION_WITHOUT_HTML}
9393
</p>
94+
{product.stockQuantity && (
95+
<p
96+
v-if="data.product.stockQuantity"
97+
class="pt-1 mt-4 mb-4 text-2xl text-gray-900"
98+
>
99+
{product.stockQuantity} på lager
100+
</p>
101+
)}
94102
{product.variations && (
95103
<p className="pt-1 mt-4 text-xl text-gray-900">
96104
<span className="py-2">Varianter</span>
97105
<select
98106
id="variant"
99107
name="variant"
100-
className="block w-64 px-6 py-2 bg-white border border-gray-500 rounded-lg focus:outline-none focus:shadow-outline"
108+
className="block w-80 px-6 py-2 bg-white border border-gray-500 rounded-lg focus:outline-none focus:shadow-outline"
101109
onChange={(e) => {
102110
setselectedVariation(e.target.value);
103111
}}
104112
>
105113
{product.variations.nodes.map(
106-
({ id, name, databaseId }) => {
114+
({ id, name, databaseId, stockQuantity }) => {
107115
// Remove product name from variation name
108116
const filteredName = name.split('- ').pop();
109117
return (
110118
<option key={id} value={databaseId}>
111-
{filteredName}
119+
{filteredName} - ({stockQuantity} på lager)
112120
</option>
113121
);
114122
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nextjs-woocommerce",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"description": "Next.js WooCommerce webshop",
55
"main": "index.js",
66
"scripts": {

utils/gql/GQL_QUERIES.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const GET_SINGLE_PRODUCT = gql`
2222
regularPrice
2323
price
2424
id
25+
stockQuantity
2526
}
2627
... on VariableProduct {
2728
salePrice

0 commit comments

Comments
 (0)