// backend/http-functions.js import { response } from 'wix-http-functions'; import { addToCurrentCart, updateCurrentCart } from 'wix-ecom-backend/current-cart'; import { createCheckoutFromCurrentCart } from 'wix-ecom-backend/current-cart'; import { getCheckoutUrl } from 'wix-ecom-backend/checkout'; // GET /_functions/metaCheckout?products=123:2,456:1 export async function get_metaCheckout(request) { try { const url = new URL(request.url); const raw = url.searchParams.get('products'); // Meta sends URL-encoded; Wix gives you raw here if (!raw) return badRequest('Missing products'); // 1) Clear the cart (set to empty) await updateCurrentCart({ lineItems: [] }); // clears any stale items // 2) Parse items like "123:2,456:1" const lineItems = []; decodeURIComponent(raw).split(',').forEach(pair => { const [idStr, qtyStr] = pair.split(':'); const productId = (idStr || '').trim(); const quantity = Number(qtyStr); if (productId && quantity > 0) { lineItems.push({ quantity, catalogReference: { // Wix Stores appId (keep as-is) appId: '1380b703-ce81-ff05-f115-39571d94dfcd', catalogItemId: productId // If you use variants, include variant info per your catalog setup. } }); } }); if (!lineItems.length) return badRequest('No valid products'); // 3) Add all items to the current visitor's cart await addToCurrentCart({ lineItems }); // 4) Create a checkout based on the current cart const { checkout } = await createCheckoutFromCurrentCart(); // 5) Get the native Wix checkout URL and 302 redirect the shopper there const { checkoutUrl } = await getCheckoutUrl(checkout._id); return redirect302(checkoutUrl); } catch (err) { console.error('metaCheckout error:', err); return response({ status: 500, headers: { 'Content-Type': 'application/json' }, body: { error: 'server_error' } }); } } function badRequest(msg) { return response({ status: 400, headers: { 'Content-Type': 'application/json' }, body: { error: msg } }); } function redirect302(location) { return response({ status: 302, // temporary redirect headers: { Location: location } }); }
top of page

MENOPAUSE MANAGEMENT

Bounce Back with Balanced Hormones

Experience renewed energy, balance, and wellness with Bare Soul's Hormone Replacement Therapy (HRT) for perimenopause and menopause, including lifestyle management and medications. Our goal is to help you manage your symptoms and improve your quality of life during this new phase!

Bare-Soul.png
BARE-07544.jpg

Frequently asked questions

bare--3297.jpg

Start Your Journey

Ready to get started on your customized wellness journey? Whether you're looking for weight loss, HRT or comprehensive skin care, we are proud to be your one-stop-shop for all of your wellness and aesthetic needs!

LOCATION

200 Closter Dock Rd, 2nd Fl,
Closter, NJ 07624

CONTACT

201-564-7521
wecare@getbare.com

bottom of page