From 531da950915f99d85fbceda4ec0b0be78f3981d5 Mon Sep 17 00:00:00 2001 From: Ben Miller Date: Sat, 16 Nov 2024 05:24:19 -0700 Subject: [PATCH] fixes to create new products --- src/Product.ts | 8 ++++++-- src/shopifyApi.ts | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Product.ts b/src/Product.ts index af76d05..eea6339 100644 --- a/src/Product.ts +++ b/src/Product.ts @@ -128,7 +128,9 @@ export class Product { let sps = new ShopifyProductSetInput() //TODO: map category IDs //sps.category = this.category - sps.id = this.shopify_id + if (this.shopify_id != "") { + sps.id = this.shopify_id + } if (this.shopify_status.match('DRAFT|ACTIVE|ARCHIVED')) { sps.status = this.shopify_status } @@ -139,7 +141,9 @@ export class Product { sps.variants = [] let variant = new ShopifyVariant() //TODO: handle multiple variants - variant.id = this.shopify_default_variant_id + if (this.shopify_default_variant_id != "") { + variant.id = this.shopify_default_variant_id + } variant.sku = this.sku variant.price = this.price sps.variants.push(variant) diff --git a/src/shopifyApi.ts b/src/shopifyApi.ts index c33e445..39a0be7 100644 --- a/src/shopifyApi.ts +++ b/src/shopifyApi.ts @@ -847,7 +847,7 @@ export class ShopifyProductSetQuery { export class ShopifyProductSetInput { category: string descriptionHtml: string - id: string + id?: string productType: string redirectNewHandle: boolean = true status: string = "DRAFT"