Browse Source

add discount price

master
azri 1 week ago
parent
commit
d6812620b0

+ 20
- 4
src/components/Header/Header.jsx View File

2
 import { createStyles, styled } from '@mui/material/styles';
2
 import { createStyles, styled } from '@mui/material/styles';
3
 import { Box, Typography, Link } from '@mui/material';
3
 import { Box, Typography, Link } from '@mui/material';
4
 import InstagramIcon from '@mui/icons-material/Instagram';
4
 import InstagramIcon from '@mui/icons-material/Instagram';
5
-import WhatsAppIcon from '@mui/icons-material/WhatsApp'; 
5
+import WhatsAppIcon from '@mui/icons-material/WhatsApp';
6
 
6
 
7
 const TikTokIcon = ({ color = "#000000" }) => {
7
 const TikTokIcon = ({ color = "#000000" }) => {
8
     return (
8
     return (
32
 
32
 
33
 const Header = () => {
33
 const Header = () => {
34
 
34
 
35
+    const scrollToBottom = () => {
36
+        window.scrollTo({
37
+            top: document.body.scrollHeight,
38
+            behavior: 'smooth',
39
+        });
40
+    };
41
+
35
     return (
42
     return (
36
         <Container>
43
         <Container>
37
             <Box sx={{ color: "white", px: 6.1 }}>
44
             <Box sx={{ color: "white", px: 6.1 }}>
39
                     <WhatsAppIcon sx={{ ":hover": { color: "gray" } }} style={headerStyle.icon} onClick={() => { window.open('https://wa.me/+60172282072', '_blank') }} />
46
                     <WhatsAppIcon sx={{ ":hover": { color: "gray" } }} style={headerStyle.icon} onClick={() => { window.open('https://wa.me/+60172282072', '_blank') }} />
40
                     <InstagramIcon sx={{ ":hover": { color: "gray" } }} style={headerStyle.icon} onClick={() => { window.open('https://www.instagram.com/amber.officials/?hl=en', '_blank') }} />
47
                     <InstagramIcon sx={{ ":hover": { color: "gray" } }} style={headerStyle.icon} onClick={() => { window.open('https://www.instagram.com/amber.officials/?hl=en', '_blank') }} />
41
                     <a onClick={() => { window.open('https://www.tiktok.com/@ambermodeofficial', '_blank') }}>
48
                     <a onClick={() => { window.open('https://www.tiktok.com/@ambermodeofficial', '_blank') }}>
42
-                    <TikTokIcon color={"#FFF"}/>
49
+                        <TikTokIcon color={"#FFF"} />
43
                     </a>
50
                     </a>
44
-                    
51
+
45
                 </Box>
52
                 </Box>
46
-                <Typography variant="body2" sx={{ position: "absolute", top: "50%", left: "50%", transform: "translate(-50%, -50%)" }}>Don’t miss out on our next big thing! Click <a style={{ color: "white", textDecoration: "underline", cursor: 'pointer' }}> here</a> to subcribe now.</Typography>
53
+                <Typography variant="body2" sx={{ position: "absolute", top: "50%", left: "50%", transform: "translate(-50%, -50%)" }}>Don’t miss out on our next big thing! Click  <span
54
+                    onClick={scrollToBottom}
55
+                    style={{
56
+                        color: 'white',
57
+                        textDecoration: 'underline',
58
+                        cursor: 'pointer',
59
+                    }}
60
+                >
61
+                    here
62
+                </span> to subcribe now.</Typography>
47
             </Box>
63
             </Box>
48
         </Container>
64
         </Container>
49
     );
65
     );

+ 16
- 6
src/components/ProductDetails/ProductDetails.jsx View File

78
         })
78
         })
79
 
79
 
80
         // find variant price if it all match initial variant selection
80
         // find variant price if it all match initial variant selection
81
-        for (const { selectedOptions, price, id, quantityAvailable } of productVariants) {
81
+        for (const { selectedOptions, price, compareAtPrice, id, quantityAvailable } of productVariants) {
82
+
82
           let { amount, currencyCode } = price;
83
           let { amount, currencyCode } = price;
83
 
84
 
85
+          if (compareAtPrice?.amount > 0) {
86
+            amount = compareAtPrice?.amount
87
+            currencyCode = compareAtPrice?.currencyCode
88
+          }
89
+
84
           // Convert array to object
90
           // Convert array to object
85
           const optionsObject = selectedOptions.reduce(
91
           const optionsObject = selectedOptions.reduce(
86
             (a, { name, value }) => ({ ...a, [name]: value }),
92
             (a, { name, value }) => ({ ...a, [name]: value }),
107
 
113
 
108
   const handleVariantClick = (name, value) => {
114
   const handleVariantClick = (name, value) => {
109
 
115
 
110
-
111
-
112
     setVariantSelection({ ...variantSelection, [name]: value })
116
     setVariantSelection({ ...variantSelection, [name]: value })
113
 
117
 
114
     setVariantSelection((prev) => {
118
     setVariantSelection((prev) => {
118
       let productVariants = product?.variants
122
       let productVariants = product?.variants
119
 
123
 
120
       // find variant price if it all match initial variant selection
124
       // find variant price if it all match initial variant selection
121
-      for (const { selectedOptions, price, id, quantityAvailable } of productVariants) {
125
+      for (const { selectedOptions, price, compareAtPrice, id, quantityAvailable } of productVariants) {
126
+
122
         let { amount, currencyCode } = price;
127
         let { amount, currencyCode } = price;
123
 
128
 
129
+        if (compareAtPrice?.amount > 0) {
130
+          amount = compareAtPrice?.amount
131
+          currencyCode = compareAtPrice?.currencyCode
132
+        }
133
+
124
         // Convert array to object
134
         // Convert array to object
125
         const optionsObject = selectedOptions.reduce(
135
         const optionsObject = selectedOptions.reduce(
126
           (a, { name, value }) => ({ ...a, [name]: value }),
136
           (a, { name, value }) => ({ ...a, [name]: value }),
247
                     sm: "0.875rem",
257
                     sm: "0.875rem",
248
                     md: "1.1rem",
258
                     md: "1.1rem",
249
                   },
259
                   },
250
-                  mb:1
260
+                  mb: 1
251
                 }}>
261
                 }}>
252
                   {name}
262
                   {name}
253
                 </Typography>
263
                 </Typography>
286
               sm: "0.875rem",
296
               sm: "0.875rem",
287
               md: "1.1rem",
297
               md: "1.1rem",
288
             },
298
             },
289
-            mb:1
299
+            mb: 1
290
           }}>
300
           }}>
291
             Quantity
301
             Quantity
292
           </Typography>
302
           </Typography>

+ 79
- 12
src/components/ProductHistoryList/ProductHistoryList.jsx View File

10
   const products = useSelector((state) => state.products.products.data); // only used as referenced
10
   const products = useSelector((state) => state.products.products.data); // only used as referenced
11
   const [filterProducts, setFilterProducts] = useState([])
11
   const [filterProducts, setFilterProducts] = useState([])
12
 
12
 
13
-  useEffect(()=>{ 
13
+  useEffect(() => {
14
 
14
 
15
     if (products.length > 0 && localStorage.getItem('amber-product-history')) {
15
     if (products.length > 0 && localStorage.getItem('amber-product-history')) {
16
 
16
 
17
       const productHandleList = JSON.parse(localStorage.getItem('amber-product-history')) || []
17
       const productHandleList = JSON.parse(localStorage.getItem('amber-product-history')) || []
18
-      const selectedProducts = products.filter(({ handle }) => productHandleList.includes(handle) ) || []
18
+      const selectedProducts = products.filter(({ handle }) => productHandleList.includes(handle)) || []
19
 
19
 
20
       setFilterProducts(selectedProducts)
20
       setFilterProducts(selectedProducts)
21
 
21
 
23
 
23
 
24
   }, [products])
24
   }, [products])
25
 
25
 
26
-  const renderProduct = (handle, img_url, title, collection_name, minPrice, minPriceCurrency, maxPrice, maxPriceCurrency, extra_desc, selected = false) => {
26
+  const renderProduct = (
27
+    handle,
28
+    img_url,
29
+    title,
30
+    collection_name,
31
+    minPrice,
32
+    minPriceCurrency,
33
+    maxPrice,
34
+    maxPriceCurrency,
35
+    minDiscountPrice,
36
+    minDiscountPriceCurrency,
37
+    maxDiscountPrice,
38
+    maxDiscountPriceCurrency,
39
+    extra_desc,
40
+    selected = false
41
+  ) => {
27
 
42
 
28
     return (
43
     return (
29
       <Grid className="animate__animated animate__fadeIn" item size={{ xs: 6, sm: 6, md: 3 }}>
44
       <Grid className="animate__animated animate__fadeIn" item size={{ xs: 6, sm: 6, md: 3 }}>
89
               }}>
104
               }}>
90
                 {title}
105
                 {title}
91
               </Typography>
106
               </Typography>
92
-              <Typography variant="body2" sx={{
93
-                fontWeight: "100", fontSize: {
94
-                  xs: "0.73rem",
95
-                  sm: "0.73rem",
96
-                  md: "0.875rem",
97
-                },
98
-              }}>
107
+              <Typography
108
+                variant="body2"
109
+                sx={{
110
+                  fontWeight: "100",
111
+                  fontSize: {
112
+                    xs: "0.73rem",
113
+                    sm: "0.73rem",
114
+                    md: "0.875rem",
115
+                  },
116
+                  textDecoration: (minDiscountPrice > 0) ? "line-through" : "none"
117
+                }}
118
+              >
99
                 {`${minPriceCurrency} ${parseFloat(minPrice).toFixed(2)}`}
119
                 {`${minPriceCurrency} ${parseFloat(minPrice).toFixed(2)}`}
100
               </Typography>
120
               </Typography>
121
+
122
+              {(minDiscountPrice > 0) && <Typography
123
+                variant="body2"
124
+                sx={{
125
+                  fontWeight: "100",
126
+                  fontSize: {
127
+                    xs: "0.73rem",
128
+                    sm: "0.73rem",
129
+                    md: "0.875rem",
130
+                  },
131
+                }}
132
+              >
133
+                {`${minDiscountPriceCurrency} ${parseFloat(minDiscountPrice).toFixed(2)}`}
134
+              </Typography>}
101
             </Box>
135
             </Box>
102
           </Box>
136
           </Box>
103
         </a>
137
         </a>
112
       <Grid container spacing={1} columns={12}>
146
       <Grid container spacing={1} columns={12}>
113
         {filterProducts.map((product, index) => {
147
         {filterProducts.map((product, index) => {
114
 
148
 
115
-          let { handle, title, images, collections, minVariantPrice, maxVariantPrice, productType, variants, selected } = product
149
+          let {
150
+            handle,
151
+            title,
152
+            images,
153
+            collections,
154
+            minVariantPrice,
155
+            maxVariantPrice,
156
+            compareAtPriceRangeMinVariantPrice,
157
+            compareAtPriceRangeMaxVariantPrice,
158
+            productType,
159
+            variants,
160
+            selected,
161
+          } = product;
116
 
162
 
117
           let minPrice = minVariantPrice.amount
163
           let minPrice = minVariantPrice.amount
118
           let minPriceCurrency = minVariantPrice.currencyCode
164
           let minPriceCurrency = minVariantPrice.currencyCode
119
           let maxPrice = maxVariantPrice.amount
165
           let maxPrice = maxVariantPrice.amount
120
           let maxPriceCurrency = maxVariantPrice.currencyCode
166
           let maxPriceCurrency = maxVariantPrice.currencyCode
167
+          // SHOULD BE THE DISCOUNTED PRICE
168
+          let minDiscountPrice = compareAtPriceRangeMinVariantPrice.amount;
169
+          let minDiscountPriceCurrency = compareAtPriceRangeMinVariantPrice.currencyCode;
170
+          let maxDiscountPrice = compareAtPriceRangeMaxVariantPrice.amount;
171
+          let maxDiscountPriceCurrency = compareAtPriceRangeMaxVariantPrice.currencyCode;
172
+
121
           let img_url = images[0]?.url || defaultImage
173
           let img_url = images[0]?.url || defaultImage
122
           let collection_name = collections[0]?.title
174
           let collection_name = collections[0]?.title
123
 
175
 
124
           if (index < 4) {
176
           if (index < 4) {
125
-            return renderProduct(handle, img_url, title, collection_name, minPrice, minPriceCurrency, maxPrice, maxPriceCurrency, "", selected)
177
+            return renderProduct(
178
+              handle,
179
+              img_url,
180
+              title,
181
+              collection_name,
182
+              minPrice,
183
+              minPriceCurrency,
184
+              maxPrice,
185
+              maxPriceCurrency,
186
+              minDiscountPrice,
187
+              minDiscountPriceCurrency,
188
+              maxDiscountPrice,
189
+              maxDiscountPriceCurrency,
190
+              "",
191
+              selected
192
+            );
126
           }
193
           }
127
 
194
 
128
         })}
195
         })}

+ 35
- 0
src/components/ProductList/ProductList.jsx View File

173
     minPriceCurrency,
173
     minPriceCurrency,
174
     maxPrice,
174
     maxPrice,
175
     maxPriceCurrency,
175
     maxPriceCurrency,
176
+    minDiscountPrice,
177
+    minDiscountPriceCurrency,
178
+    maxDiscountPrice,
179
+    maxDiscountPriceCurrency,
176
     extra_desc,
180
     extra_desc,
177
     selected = false
181
     selected = false
178
   ) => {
182
   ) => {
183
+
179
     return (
184
     return (
180
       <Grid
185
       <Grid
181
         className="animate__animated animate__fadeIn"
186
         className="animate__animated animate__fadeIn"
255
             >
260
             >
256
               {title}
261
               {title}
257
             </Typography>
262
             </Typography>
263
+
258
             <Typography
264
             <Typography
259
               variant="body2"
265
               variant="body2"
260
               sx={{
266
               sx={{
264
                   sm: "0.73rem",
270
                   sm: "0.73rem",
265
                   md: "0.875rem",
271
                   md: "0.875rem",
266
                 },
272
                 },
273
+                textDecoration: (minDiscountPrice > 0) ? "line-through" : "none"
267
               }}
274
               }}
268
             >
275
             >
269
               {`${minPriceCurrency} ${parseFloat(minPrice).toFixed(2)}`}
276
               {`${minPriceCurrency} ${parseFloat(minPrice).toFixed(2)}`}
270
             </Typography>
277
             </Typography>
278
+
279
+            {(minDiscountPrice > 0) && <Typography
280
+              variant="body2"
281
+              sx={{
282
+                fontWeight: "100",
283
+                fontSize: {
284
+                  xs: "0.73rem",
285
+                  sm: "0.73rem",
286
+                  md: "0.875rem",
287
+                },
288
+              }}
289
+            >
290
+              {`${minDiscountPriceCurrency} ${parseFloat(minDiscountPrice).toFixed(2)}`}
291
+            </Typography>}
292
+            
293
+
271
           </Box>
294
           </Box>
272
         </Box>
295
         </Box>
273
       </Grid>
296
       </Grid>
421
               collections,
444
               collections,
422
               minVariantPrice,
445
               minVariantPrice,
423
               maxVariantPrice,
446
               maxVariantPrice,
447
+              compareAtPriceRangeMinVariantPrice,
448
+              compareAtPriceRangeMaxVariantPrice,
424
               productType,
449
               productType,
425
               variants,
450
               variants,
426
               selected,
451
               selected,
430
             let minPriceCurrency = minVariantPrice.currencyCode;
455
             let minPriceCurrency = minVariantPrice.currencyCode;
431
             let maxPrice = maxVariantPrice.amount;
456
             let maxPrice = maxVariantPrice.amount;
432
             let maxPriceCurrency = maxVariantPrice.currencyCode;
457
             let maxPriceCurrency = maxVariantPrice.currencyCode;
458
+            // SHOULD BE THE DISCOUNTED PRICE
459
+            let minDiscountPrice = compareAtPriceRangeMinVariantPrice.amount;
460
+            let minDiscountPriceCurrency = compareAtPriceRangeMinVariantPrice.currencyCode;
461
+            let maxDiscountPrice = compareAtPriceRangeMaxVariantPrice.amount;
462
+            let maxDiscountPriceCurrency = compareAtPriceRangeMaxVariantPrice.currencyCode;
463
+
433
             let img_url = images[0]?.url || defaultImage;
464
             let img_url = images[0]?.url || defaultImage;
434
             let collection_name = collections[0]?.title;
465
             let collection_name = collections[0]?.title;
435
 
466
 
443
                 minPriceCurrency,
474
                 minPriceCurrency,
444
                 maxPrice,
475
                 maxPrice,
445
                 maxPriceCurrency,
476
                 maxPriceCurrency,
477
+                minDiscountPrice,
478
+                minDiscountPriceCurrency,
479
+                maxDiscountPrice,
480
+                maxDiscountPriceCurrency,
446
                 "",
481
                 "",
447
                 selected
482
                 selected
448
               );
483
               );

+ 77
- 11
src/components/ProductSelected/ProductSelected.jsx View File

45
   };
45
   };
46
 
46
 
47
 
47
 
48
-  const renderProduct = (handle, img_url, title, collection_name, minPrice, minPriceCurrency, maxPrice, maxPriceCurrency, extra_desc) => {
48
+  const renderProduct = (
49
+    handle,
50
+    img_url,
51
+    title,
52
+    collection_name,
53
+    minPrice,
54
+    minPriceCurrency,
55
+    maxPrice,
56
+    maxPriceCurrency,
57
+    minDiscountPrice,
58
+    minDiscountPriceCurrency,
59
+    maxDiscountPrice,
60
+    maxDiscountPriceCurrency,
61
+    extra_desc,
62
+    selected = false
63
+  ) => {
49
 
64
 
50
     return (
65
     return (
51
       <Grid item size={{ xs: 6, sm: 6, md: 3 }}>
66
       <Grid item size={{ xs: 6, sm: 6, md: 3 }}>
116
               }}>
131
               }}>
117
                 {title}
132
                 {title}
118
               </Typography>
133
               </Typography>
119
-              <Typography variant="body2" sx={{
120
-                fontWeight: "100", fontSize: {
121
-                  xs: "0.73rem",
122
-                  sm: "0.73rem",
123
-                  md: "0.875rem",
124
-                },
125
-              }}>
134
+              <Typography
135
+                variant="body2"
136
+                sx={{
137
+                  fontWeight: "100",
138
+                  fontSize: {
139
+                    xs: "0.73rem",
140
+                    sm: "0.73rem",
141
+                    md: "0.875rem",
142
+                  },
143
+                  textDecoration: (minDiscountPrice > 0) ? "line-through" : "none"
144
+                }}
145
+              >
126
                 {`${minPriceCurrency} ${parseFloat(minPrice).toFixed(2)}`}
146
                 {`${minPriceCurrency} ${parseFloat(minPrice).toFixed(2)}`}
127
               </Typography>
147
               </Typography>
148
+
149
+              {(minDiscountPrice > 0) && <Typography
150
+                variant="body2"
151
+                sx={{
152
+                  fontWeight: "100",
153
+                  fontSize: {
154
+                    xs: "0.73rem",
155
+                    sm: "0.73rem",
156
+                    md: "0.875rem",
157
+                  },
158
+                }}
159
+              >
160
+                {`${minDiscountPriceCurrency} ${parseFloat(minDiscountPrice).toFixed(2)}`}
161
+              </Typography>}
128
             </Box>
162
             </Box>
129
           </Box>
163
           </Box>
130
         </a>
164
         </a>
161
           }}
195
           }}
162
           onClick={swipeToLeft}
196
           onClick={swipeToLeft}
163
         />
197
         />
164
-        <Typography variant="h4" sx={{ mx: 2, fontWeight:"50" }}>
198
+        <Typography variant="h4" sx={{ mx: 2, fontWeight: "50" }}>
165
           NEW IN
199
           NEW IN
166
         </Typography>
200
         </Typography>
167
 
201
 
189
         >
223
         >
190
           {filterProducts.map((product, index) => {
224
           {filterProducts.map((product, index) => {
191
 
225
 
192
-            let { handle, title, images, collections, minVariantPrice, maxVariantPrice, productType, variants } = product
226
+            let {
227
+              handle,
228
+              title,
229
+              images,
230
+              collections,
231
+              minVariantPrice,
232
+              maxVariantPrice,
233
+              compareAtPriceRangeMinVariantPrice,
234
+              compareAtPriceRangeMaxVariantPrice,
235
+              productType,
236
+              variants,
237
+              selected,
238
+            } = product;
193
 
239
 
194
             let minPrice = minVariantPrice.amount
240
             let minPrice = minVariantPrice.amount
195
             let minPriceCurrency = minVariantPrice.currencyCode
241
             let minPriceCurrency = minVariantPrice.currencyCode
196
             let maxPrice = maxVariantPrice.amount
242
             let maxPrice = maxVariantPrice.amount
197
             let maxPriceCurrency = maxVariantPrice.currencyCode
243
             let maxPriceCurrency = maxVariantPrice.currencyCode
244
+            // SHOULD BE THE DISCOUNTED PRICE
245
+            let minDiscountPrice = compareAtPriceRangeMinVariantPrice.amount;
246
+            let minDiscountPriceCurrency = compareAtPriceRangeMinVariantPrice.currencyCode;
247
+            let maxDiscountPrice = compareAtPriceRangeMaxVariantPrice.amount;
248
+            let maxDiscountPriceCurrency = compareAtPriceRangeMaxVariantPrice.currencyCode;
198
 
249
 
199
             let img_url = images[0]?.url || defaultImage
250
             let img_url = images[0]?.url || defaultImage
200
             let collection_name = collections[0]?.title
251
             let collection_name = collections[0]?.title
201
 
252
 
202
             return (
253
             return (
203
               <SwiperSlide>
254
               <SwiperSlide>
204
-                {renderProduct(handle, img_url, title, collection_name, minPrice, minPriceCurrency, maxPrice, maxPriceCurrency, "")}
255
+                {renderProduct(
256
+                  handle,
257
+                  img_url,
258
+                  title,
259
+                  collection_name,
260
+                  minPrice,
261
+                  minPriceCurrency,
262
+                  maxPrice,
263
+                  maxPriceCurrency,
264
+                  minDiscountPrice,
265
+                  minDiscountPriceCurrency,
266
+                  maxDiscountPrice,
267
+                  maxDiscountPriceCurrency,
268
+                  "",
269
+                  selected
270
+                )}
205
               </SwiperSlide>
271
               </SwiperSlide>
206
             )
272
             )
207
 
273
 

+ 31
- 0
src/components/ProductSuggestion/ProductSuggestion.jsx View File

33
     minPriceCurrency,
33
     minPriceCurrency,
34
     maxPrice,
34
     maxPrice,
35
     maxPriceCurrency,
35
     maxPriceCurrency,
36
+    minDiscountPrice,
37
+    minDiscountPriceCurrency,
38
+    maxDiscountPrice,
39
+    maxDiscountPriceCurrency,
36
     extra_desc,
40
     extra_desc,
37
     selected = false
41
     selected = false
38
   ) => {
42
   ) => {
125
                     sm: "0.73rem",
129
                     sm: "0.73rem",
126
                     md: "0.875rem",
130
                     md: "0.875rem",
127
                   },
131
                   },
132
+                  textDecoration: (minDiscountPrice > 0) ? "line-through" : "none"
128
                 }}
133
                 }}
129
               >
134
               >
130
                 {`${minPriceCurrency} ${parseFloat(minPrice).toFixed(2)}`}
135
                 {`${minPriceCurrency} ${parseFloat(minPrice).toFixed(2)}`}
131
               </Typography>
136
               </Typography>
137
+
138
+              {(minDiscountPrice > 0) && <Typography
139
+                variant="body2"
140
+                sx={{
141
+                  fontWeight: "100",
142
+                  fontSize: {
143
+                    xs: "0.73rem",
144
+                    sm: "0.73rem",
145
+                    md: "0.875rem",
146
+                  },
147
+                }}
148
+              >
149
+                {`${minDiscountPriceCurrency} ${parseFloat(minDiscountPrice).toFixed(2)}`}
150
+              </Typography>}
132
             </Box>
151
             </Box>
133
           </Box>
152
           </Box>
134
         </a>
153
         </a>
149
             collections,
168
             collections,
150
             minVariantPrice,
169
             minVariantPrice,
151
             maxVariantPrice,
170
             maxVariantPrice,
171
+            compareAtPriceRangeMinVariantPrice,
172
+            compareAtPriceRangeMaxVariantPrice,
152
             productType,
173
             productType,
153
             variants,
174
             variants,
154
             selected,
175
             selected,
158
           let minPriceCurrency = minVariantPrice.currencyCode;
179
           let minPriceCurrency = minVariantPrice.currencyCode;
159
           let maxPrice = maxVariantPrice.amount;
180
           let maxPrice = maxVariantPrice.amount;
160
           let maxPriceCurrency = maxVariantPrice.currencyCode;
181
           let maxPriceCurrency = maxVariantPrice.currencyCode;
182
+          // SHOULD BE THE DISCOUNTED PRICE
183
+          let minDiscountPrice = compareAtPriceRangeMinVariantPrice.amount;
184
+          let minDiscountPriceCurrency = compareAtPriceRangeMinVariantPrice.currencyCode;
185
+          let maxDiscountPrice = compareAtPriceRangeMaxVariantPrice.amount;
186
+          let maxDiscountPriceCurrency = compareAtPriceRangeMaxVariantPrice.currencyCode;
187
+
161
           let img_url = images[0]?.url || defaultImage
188
           let img_url = images[0]?.url || defaultImage
162
           let collection_name = collections[0]?.title;
189
           let collection_name = collections[0]?.title;
163
 
190
 
170
             minPriceCurrency,
197
             minPriceCurrency,
171
             maxPrice,
198
             maxPrice,
172
             maxPriceCurrency,
199
             maxPriceCurrency,
200
+            minDiscountPrice,
201
+            minDiscountPriceCurrency,
202
+            maxDiscountPrice,
203
+            maxDiscountPriceCurrency,
173
             "",
204
             "",
174
             selected
205
             selected
175
           );
206
           );

+ 14
- 0
src/services/ProductService.js View File

35
               currencyCode
35
               currencyCode
36
             }
36
             }
37
           }
37
           }
38
+          compareAtPriceRange {
39
+            maxVariantPrice {
40
+              currencyCode
41
+              amount
42
+            }
43
+            minVariantPrice {
44
+              amount
45
+              currencyCode
46
+            }
47
+          }
38
           images(first: 4) {
48
           images(first: 4) {
39
             nodes {
49
             nodes {
40
               url
50
               url
143
             value
153
             value
144
           }
154
           }
145
           quantityAvailable
155
           quantityAvailable
156
+          compareAtPrice {
157
+            currencyCode
158
+            amount
159
+          }
146
         }
160
         }
147
       }
161
       }
148
       metafield(key: "selected", namespace: "custom") {
162
       metafield(key: "selected", namespace: "custom") {

+ 5
- 2
src/utils/helpers.js View File

4
 export const formatProductData = (product) => {
4
 export const formatProductData = (product) => {
5
 
5
 
6
     if(!product) return
6
     if(!product) return
7
-
7
+    
8
     return {
8
     return {
9
         id: product?.id || null,
9
         id: product?.id || null,
10
         handle: product?.handle || "",
10
         handle: product?.handle || "",
17
         selected: (product?.metafield?.key == "selected") ? product?.metafield?.value == "true" : false, // cause I want to have a true false value, somehow BE return text value "true", thus == used to convert it to proper boolean value
17
         selected: (product?.metafield?.key == "selected") ? product?.metafield?.value == "true" : false, // cause I want to have a true false value, somehow BE return text value "true", thus == used to convert it to proper boolean value
18
         minVariantPrice: product?.priceRange?.minVariantPrice || {amount:0 , currencyCode:''},
18
         minVariantPrice: product?.priceRange?.minVariantPrice || {amount:0 , currencyCode:''},
19
         maxVariantPrice: product?.priceRange?.maxVariantPrice || {amount:0 , currencyCode:''},
19
         maxVariantPrice: product?.priceRange?.maxVariantPrice || {amount:0 , currencyCode:''},
20
+        compareAtPriceRangeMinVariantPrice: product?.compareAtPriceRange?.minVariantPrice || {amount:0 , currencyCode:''},
21
+        compareAtPriceRangeMaxVariantPrice: product?.compareAtPriceRange?.maxVariantPrice || {amount:0 , currencyCode:''},
20
         productType: product?.productType || null,
22
         productType: product?.productType || null,
21
-        variants: product?.variants?.nodes || null
23
+        variants: product?.variants?.nodes || null,
24
+        
22
     }
25
     }
23
 
26
 
24
 }
27
 }

Loading…
Cancel
Save