Browse Source

reuse default shipping profile, if available

Shahed Nasser 4 months ago
parent
commit
0eae25a828
1 changed files with 10 additions and 3 deletions
  1. 10 3
      src/scripts/seed.ts

+ 10 - 3
src/scripts/seed.ts

@@ -122,18 +122,25 @@ export default async function seedDemoData({ container }: ExecArgs) {
   });
 
   logger.info("Seeding fulfillment data...");
-  const { result: shippingProfileResult } =
+  const shippingProfiles = await fulfillmentModuleService.listShippingProfiles({
+    type: "default"
+  })
+  let shippingProfile = shippingProfiles.length ? shippingProfiles[0] : null
+
+  if (!shippingProfile) {
+    const { result: shippingProfileResult } =
     await createShippingProfilesWorkflow(container).run({
       input: {
         data: [
           {
-            name: "Default",
+            name: "Default Shipping Profile",
             type: "default",
           },
         ],
       },
     });
-  const shippingProfile = shippingProfileResult[0];
+    shippingProfile = shippingProfileResult[0];
+  }
 
   const fulfillmentSet = await fulfillmentModuleService.createFulfillmentSets({
     name: "European Warehouse delivery",