Skip to content

Commit 23adce2

Browse files
committed
Add basic support for displaying variations
1 parent 03d4492 commit 23adce2

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

components/Product/SingleProduct.component.jsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ const SingleProduct = ({ product }) => {
1414
setIsLoading(false);
1515
}, []);
1616

17-
console.log("Product information: ");
18-
console.log(product);
17+
//console.log("Product information: ");
18+
//console.log(product);
1919

2020
const {
2121
description,
@@ -72,6 +72,27 @@ const SingleProduct = ({ product }) => {
7272
<p className="pt-1 mt-4 text-2xl text-gray-900">
7373
{DESCRIPTION_WITHOUT_HTML}
7474
</p>
75+
76+
{product.variations && (
77+
<p className="pt-1 mt-4 text-xl text-gray-900">
78+
<span className="py-2">Varianter</span>
79+
<select
80+
id="farge"
81+
className="block w-64 px-6 py-2 bg-white border border-gray-500 rounded-lg focus:outline-none focus:shadow-outline"
82+
>
83+
{product.variations.nodes.map(({ id, name }) => {
84+
const filteredName = name.split('-').pop();
85+
86+
return (
87+
<option key={id} value={filteredName}>
88+
{filteredName}
89+
</option>
90+
);
91+
})}
92+
</select>
93+
</p>
94+
)}
95+
7596
{/*
7697
<p className="pt-1 mt-4 text-xl text-gray-900">
7798
<span className="py-2">Farge</span>

utils/const/GQL_QUERIES.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@ export const GET_SINGLE_PRODUCT = gql`
3737
nodes {
3838
id
3939
name
40-
stockStatus
41-
price
40+
stockStatus
4241
stockQuantity
42+
purchasable
43+
onSale
44+
salePrice
45+
regularPrice
4346
}
4447
}
4548
}

0 commit comments

Comments
 (0)