I can update a row!

This commit is contained in:
Ben Miller
2024-11-16 04:51:23 -07:00
parent ca48bb6572
commit 6dd205dcbb
4 changed files with 73 additions and 7 deletions

View File

@ -138,9 +138,7 @@ export class Product {
variant.sku = this.sku
variant.price = this.price
sps.variants.push(variant)
let opt = new ShopifyVa
let options = new VariantOptionValueInput()
options.id = this.shopify_default_option_value_id
console.log("ToShopifyProductSet:\n" + JSON.stringify(sps, null, 2))
return sps
}

View File

@ -16,6 +16,8 @@
/// <reference types="@types/google-apps-script" />
import { Config } from "./config"
import * as shopify from "shopify-admin-api-typings"
import gql from 'graphql-tag'
const ss = SpreadsheetApp.getActive()
@ -731,7 +733,13 @@ export class ShopifyVariant {
barcode?: string
position?: number
nodes?: ShopifyProductVariant[]
optionValues?: VariantOptionValueInput[]
//TODO: support multiple options
optionValues: [{}] = [
{
optionName: "Title",
name: "Default Title"
}
]
}
class PageInfo {
@ -802,7 +810,7 @@ export class ShopifyProductsResponse {
}
export class ShopifyProductSetQuery {
GQL: string = `mutation setProduct($productSet: ProductSetInput!) {
GQL = `mutation setProduct($productSet: ProductSetInput!) {
productSet(input: $productSet) {
product {
id
@ -826,7 +834,7 @@ export class ShopifyProductSetQuery {
JSON: JSON
constructor(product: ShopifyProductSetInput, synchronous: boolean = true) {
let j = `{
"query": ${formatGqlForJSON(this.GQL)},
"query": ${formatGqlForJSON(String(this.GQL))},
"variables": {
"productSet": ${JSON.stringify(product)}
}
@ -847,7 +855,15 @@ export class ShopifyProductSetInput {
title: string
vendor: string
variants: ShopifyVariant[]
productOptions: ShopifyProductOption[]
//TODO: Support multiple product options
productOptions: [{}] = [
{
name: "Title",
values: {
name: "Default Title"
}
}
]
}
export class ProductVariantSetInput {