top of page

Forum Posts

Ricardo Alegría
Jun 13, 2024
In Velo (Wix Code)
I'm trying to access the getCurrentCart API in a backend file called "cart.web.js" This is the code in "cart.web.js": import {Permissions, webMethod} from 'wix-web-module'; import { currentCart } from "wix-ecom-backend"; export const myGetCurrentCartFunction = webMethod( Permissions.Anyone, async () => { try { const myCurrentCart = await currentCart.getCurrentCart(); console.log("Success! Retrieved current cart:", currentCart); return myCurrentCart; } catch (error) { console.error(error); // Handle the error } }, ); As you can see, is the same code suggested in the VELO Docs. so when I try to run the myGetCurrentCartFunction it returns me an error like the following: I also added some code to the "CART PAGE" in order to access myGetCurrentCartFunction import { myGetCurrentCartFunction } from 'backend/cart.web'; $w.onReady(function () { const getCurrentCart = async() => { const cart = await myGetCurrentCartFunction(); console.log(cart); } getCurrentCart(); }); The same error is returned even in the preview mode Any ideas?
Cart not found: Cannot find cart by ownership when using getCurrentCart API content media
0
2
210
Ricardo Alegría

Ricardo Alegría

More actions
bottom of page