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++) { for (let row = e.range.getRow(); row <= e.range.getLastRow(); row++) {
console.log("row: " + row) console.log("row: " + row)
let updateString = "updating " + header + " on row " + row let updateString = "updating " + header + " on row " + row
toastAndLog(updateString)
switch (header) { switch (header) {
case "shopify_status": case "shopify_status":
toastAndLog(updateString)
updateProductToShopify(row) updateProductToShopify(row)
break break
case "title": case "title":
updateProductToShopify(row) toastAndLog(updateString)
break
case "category":
updateProductToShopify(row) updateProductToShopify(row)
break break
case "product_type": case "product_type":
toastAndLog(updateString)
updateProductToShopify(row) updateProductToShopify(row)
break break
case "tags": case "tags":
toastAndLog(updateString)
updateProductToShopify(row) updateProductToShopify(row)
break break
case "description": case "description":
toastAndLog(updateString)
updateProductToShopify(row) updateProductToShopify(row)
break break
case "price": case "price":
toastAndLog(updateString)
updateProductToShopify(row) updateProductToShopify(row)
break break
default: default:

View File

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