Hi everyone !
I’m trying to display the subtotal price of all product in cart on home page.
Can you help me please ?
Hi everyone !
I’m trying to display the subtotal price of all product in cart on home page.
Can you help me please ?
Hello,
I think that getCurrentCart() should suit your needs. Using it, you can get the information about the products added to a cart.
https://www.wix.com/corvid/reference/wix-stores-backend.html#getCurrentCart
Corvid Web Modules: Calling Server-Side Code from the Front-End
Thanks for your reply,
but can you help me for include this on my site because i don’t understand where add this ^^
Resolved:
I solved my problem thank you ^^
I did this:
With developer mode, I added a file in Backend in site structure named getCurrentCart.jsw and in this file i wrote this :
import wixStores from ‘wix-stores-backend’
export function getCurrentCart() {
return wixStores.getCurrentCart();
}
Next on the home page on the site code in the site tab i added this :
import wixStores from ‘wix-stores’ ;
import {getCurrentCart} from ‘backend/getCurrentCart.jsw’ ;
$w.onReady( async function () {
const results = await getCurrentCart();
$w( “#text23” ).text = results.totals.subtotal.toString();
$w( “#text24” ).text = results.currency.symbol;
console.log(getCurrentCart);
});
Finally I added 2 TextBoxes on my page and it works