Просмотр исходного кода

feat module 6, 7 : pull note data from shopify, include note identifiers in product service

master
nadia 2 дней назад
Родитель
Сommit
d4b403828f
2 измененных файлов: 36 добавлений и 0 удалений
  1. 35
    0
      src/components/ProductDetails/ProductDetails.jsx
  2. 1
    0
      src/services/ProductService.js

+ 35
- 0
src/components/ProductDetails/ProductDetails.jsx Просмотреть файл

@@ -400,6 +400,7 @@ const ProductDetails = () => {
400 400
   const careInstructionMetafield = product?.metafields?.care_instruction
401 401
   const shippingInformationMetafield = product?.metafields?.shipping_information
402 402
   const returnExchangeMetafield = product?.metafields?.return_exchange
403
+  const noteMetafield = product?.metafields?.note
403 404
   const productDetailsMetafield = product?.metafields?.product_details
404 405
   const sizeChartMetafield = product?.metafields?.size_chart
405 406
   const sizeChartImageUrl = sizeChartMetafield?.reference?.image?.url || sizeChartMetafield?.reference?.url || ""
@@ -470,6 +471,22 @@ const ProductDetails = () => {
470 471
     </Box>
471 472
   )
472 473
 
474
+  // Renders Shopify product metafield custom.note inside the Note row.
475
+  const notePanel = noteMetafield?.value ? (
476
+    <Box sx={infoPanelSx}>
477
+      <Collapse in={Boolean(expandedInfoRows.note)} timeout="auto">
478
+        <Box
479
+          sx={{
480
+            ...infoPanelContentSx,
481
+            minHeight: noteMetafield.value ? 0 : 28,
482
+          }}
483
+        >
484
+          {renderShopifyRichText(noteMetafield.value)}
485
+        </Box>
486
+      </Collapse>
487
+    </Box>
488
+  ) : null
489
+
473 490
   // Renders Shopify product metafield custom.product_details inside the Product Details row.
474 491
   const productDetailsPanel = (
475 492
     <Box sx={infoPanelSx}>
@@ -936,6 +953,24 @@ const ProductDetails = () => {
936 953
             {expandedInfoRows.returnExchanges ? <RemoveIcon sx={{ fontSize: 18 }} /> : <AddIcon sx={{ fontSize: 18 }} />}
937 954
           </Box>
938 955
           {returnExchangesPanel}
956
+
957
+          {/* Note */}
958
+          {noteMetafield?.value && (
959
+            <Box
960
+              onClick={() => toggleInfoRow("note")}
961
+              sx={{
962
+                ...infoRowSx(expandedInfoRows.note),
963
+                pb: 2,
964
+                borderBottom: "none"
965
+              }}
966
+            >
967
+              <Typography variant="body2" sx={{ textTransform: "uppercase", fontWeight: "400", fontSize: { xs: "0.875rem", md: "1.1rem" } }}>
968
+                Note
969
+              </Typography>
970
+              {expandedInfoRows.note ? <RemoveIcon sx={{ fontSize: 18 }} /> : <AddIcon sx={{ fontSize: 18 }} />}
971
+            </Box>
972
+          )}
973
+          {notePanel}
939 974
         </Box>
940 975
       </Box>
941 976
 

+ 1
- 0
src/services/ProductService.js Просмотреть файл

@@ -185,6 +185,7 @@ const getProduct = async (handle = "") => {
185 185
           {key: "care_instruction", namespace: "custom"},
186 186
           {key: "shipping_information", namespace: "custom"},
187 187
           {key: "return_exchange", namespace: "custom"},
188
+          {key: "note", namespace: "custom"},
188 189
           {key: "product_details", namespace: "custom"},
189 190
           {key: "size_chart", namespace: "custom"}
190 191
         ]

Загрузка…
Отмена
Сохранить