add compare_at_price support

This commit is contained in:
Ben Miller
2024-11-17 10:30:35 -07:00
parent a1f5e04797
commit dc97a0001a
2 changed files with 10 additions and 4 deletions

View File

@ -43,27 +43,29 @@ export function columnOnEditHandler(e: GoogleAppsScript.Events.SheetsOnEdit) {
for (let row = e.range.getRow(); row <= e.range.getLastRow(); row++) {
console.log("row: " + row)
let updateString = "updating " + header + " on row " + row
toastAndLog(updateString)
switch (header) {
case "shopify_status":
toastAndLog(updateString)
updateProductToShopify(row)
break
case "title":
updateProductToShopify(row)
break
case "category":
toastAndLog(updateString)
updateProductToShopify(row)
break
case "product_type":
toastAndLog(updateString)
updateProductToShopify(row)
break
case "tags":
toastAndLog(updateString)
updateProductToShopify(row)
break
case "description":
toastAndLog(updateString)
updateProductToShopify(row)
break
case "price":
toastAndLog(updateString)
updateProductToShopify(row)
break
default:

View File

@ -25,6 +25,7 @@ export class Product {
description: string = ""
sku: string = ""
price: number = 0
compare_at_price: number = 0
shipping: number = 0
function: string = ""
type: string = ""
@ -119,6 +120,9 @@ export class Product {
}
variant.sku = this.sku
variant.price = this.price
if (this.compare_at_price > 0) {
variant.compareAtPrice = this.compare_at_price
}
sps.variants.push(variant)
console.log("ToShopifyProductSet:\n" + JSON.stringify(sps, null, 2))
//TODO: add initial inventory