hooking up commerce

This commit is contained in:
Dominic Ferrando
2025-09-20 21:02:00 -04:00
parent 0555793bf3
commit 9ba60fa1f3
5 changed files with 171 additions and 24 deletions
+31
View File
@@ -0,0 +1,31 @@
import { Printful } from '$lib/services/commerce/printful';
import { Webflow } from '$lib/services/commerce/webflow';
import type { PageServerLoad } from './$types';
const productsStore = {
cache: {
printful: undefined as Printful.Products.SyncProduct["sync_product"][] | undefined,
webflow: undefined as Webflow.Products.Product[] | undefined,
},
getPrintfulProducts: async () => {
if (!productsStore.cache.printful) {
productsStore.cache.printful = await Printful.Products.getAll()
}
return productsStore.cache.printful;
},
getWebflowProducts: async () => {
if (!productsStore.cache.webflow) {
productsStore.cache.webflow = await Webflow.Products.getAll()
}
return productsStore.cache.webflow;
}
};
export const load = async ({ }: Parameters<PageServerLoad>[0]) => {
return {
products: {
printful: productsStore.getPrintfulProducts(),
webflow: productsStore.getWebflowProducts(),
}
};
};