Bläddra i källkod

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

master
nadia 11 timmar sedan
förälder
incheckning
c7100abe67
2 ändrade filer med 37 tillägg och 3 borttagningar
  1. 35
    2
      src/components/ProductDetails/ProductDetails.jsx
  2. 2
    1
      src/services/ProductService.js

+ 35
- 2
src/components/ProductDetails/ProductDetails.jsx Visa fil

@@ -400,6 +400,7 @@ const ProductDetails = () => {
400 400
 
401 401
   const materialMetafield = product?.metafields?.material
402 402
   const careInstructionMetafield = product?.metafields?.care_instruction
403
+  const shippingInformationMetafield = product?.metafields?.shipping_information
403 404
 
404 405
   // Renders Shopify product metafield custom.material inside the Material row.
405 406
   const materialPanel = (
@@ -453,6 +454,34 @@ const ProductDetails = () => {
453 454
     </Box>
454 455
   )
455 456
 
457
+  // Renders Shopify product metafield custom.shipping_information inside the Shipping Information row.
458
+  const shippingInformationPanel = (
459
+    <Box
460
+      sx={{
461
+        maxHeight: expandedInfoRows.shippingInformation ? 600 : 0,
462
+        overflow: "hidden",
463
+        borderBottom: "1px solid #DDD",
464
+        transition: "max-height 0.25s ease-in-out"
465
+      }}
466
+    >
467
+      <Box
468
+        sx={{
469
+          // Old extra panel spacing kept for reference:
470
+          // pb: 3,
471
+          color: "text.secondary",
472
+          minHeight: shippingInformationMetafield?.value ? 0 : 28,
473
+          fontSize: {
474
+            xs: "0.875rem",
475
+            md: "1rem"
476
+          },
477
+          lineHeight: 1.6
478
+        }}
479
+      >
480
+        {renderShopifyRichText(shippingInformationMetafield?.value)}
481
+      </Box>
482
+    </Box>
483
+  )
484
+
456 485
   const productDetailsPanel = (
457 486
     <Box
458 487
       sx={{
@@ -892,14 +921,18 @@ const ProductDetails = () => {
892 921
           {/* Shipping Information */}
893 922
           <Box
894 923
             onClick={() => toggleInfoRow("shippingInformation")}
895
-            sx={infoRowSx(expandedInfoRows.shippingInformation)}
924
+            sx={{
925
+              ...infoRowSx(expandedInfoRows.shippingInformation),
926
+              pb: 2,
927
+              borderBottom: "none"
928
+            }}
896 929
           >
897 930
             <Typography variant="body2" sx={{ textTransform: "uppercase", fontWeight: "400", fontSize: { xs: "0.875rem", md: "1.1rem" } }}>
898 931
               Shipping Information
899 932
             </Typography>
900 933
             {expandedInfoRows.shippingInformation ? <RemoveIcon sx={{ fontSize: 18 }} /> : <AddIcon sx={{ fontSize: 18 }} />}
901 934
           </Box>
902
-          {emptyInfoPanel("shippingInformation")}
935
+          {shippingInformationPanel}
903 936
 
904 937
           {/* Return & Exchanges */}
905 938
           <Box

+ 2
- 1
src/services/ProductService.js Visa fil

@@ -168,7 +168,8 @@ const getProduct = async (handle = "") => {
168 168
           {key: "published_date", namespace: "custom"},
169 169
           {key: "selected", namespace: "custom"},
170 170
           {key: "material", namespace: "custom"},
171
-          {key: "care_instruction", namespace: "custom"}
171
+          {key: "care_instruction", namespace: "custom"},
172
+          {key: "shipping_information", namespace: "custom"}
172 173
         ]
173 174
       ) {
174 175
         namespace

Laddar…
Avbryt
Spara