
import { cart } from 'wix-stores-backend'; // Backend package - not @wix/stores import wixData from 'wix-data'; const WIX_STORES_APP_ID = '215238eb-22a5-4c36-9e7b-e7c08025e04e'; export async function createMetaCheckout(data) { const { products, coupon } = data; console.log('Meta checkout request:', JSON.stringify(products)); let lineItems = []; for (const p of products) { let fullId = p.metaSku; // "15ac8586...-cd3a04e7..." let productId = null; let variantId = null; // Split productId-variantId format if (fullId.includes('-') && fullId.split('-').length === 10) { const parts = fullId.split('-'); productId = parts.slice(0, 5).join('-'); variantId = fullId; console.log(`Parsed variant ${variantId} -> product ${productId}`); } else if (fullId.includes('-') && fullId.split('-').length === 5) { productId = fullId; variantId = null; } else { throw new Error(`Invalid ID format: ${fullId}`); } let catalogReference = { appId: WIX_STORES_APP_ID, catalogItemId: productId }; // For wix-stores-backend, you MUST use options.variantId if (variantId && variantId !== productId) { catalogReference.options = { variantId: variantId }; } lineItems.push({ catalogReference, quantity: p.quantity }); } console.log('Creating cart with lineItems:', JSON.stringify(lineItems)); const newCart = await cart.createCart({ lineItems }); if (coupon) { try { await cart.applyCoupon(newCart._id, coupon); } catch (e) { console.warn('Coupon failed:', e.message); } } const checkoutUrl = `https://www.geeksetpodcast.com/checkout?cartId=${newCart._id}`; console.log('Checkout URL:', checkoutUrl); return checkoutUrl; } export async function use_createCheckout(products, coupon) { return await createMetaCheckout({ products, coupon }); }
Welcome to Geekset

The Only Place that Blends Hip-Hop Culture & Geek Culture togethere in one place.
The Geekset Podcast
The Geekset Podcast


Geekset Podcast LIVE 5-24-26 #Geekset #GeeksetPodcast

Geekset Podcast LIVE 5-3-26 #Geekset #GeeksetPodcast

Geekset Podcast LIVE 3-22-26 #Geekset #GeeksetPodcast

Geekset Podcast LIVE 3-15-26 #Geekset #GeeksetPodcast
WATCH




























