Hello, I have a Wix store and I want that when a purchase exceeds 800 USD, 40% interest is added to the purchase. How can I achieve that? I imagine from the backend. But I’m not very clear about the wix-ecom api.
I also want the user to only be able to make a purchase of up to 3000 dollars per day.
I would appreciate your help
I currently only have this on the cart page:
import { cart } from ‘wix-stores’;
import wixWindow from ‘wix-window’;
$w.onReady(function () {
// Comprueba el carrito al cargar la página
checkCartTotal();
});
function checkCartTotal() {
cart.getCurrentCart()
.then((currentCart) => {
let totalAmount = currentCart.totals.total;
if (totalAmount > 100) {
// Agregar el 40% al total
totalAmount += totalAmount * 0.4;
console.log(`El total supera los 800 USD. Se ha agregado un 40% de impuestos. Nuevo total: ${totalAmount.toFixed(2)} USD`);
wixWindow.openLightbox('myModal');
}
if (totalAmount > 100) {
console.log("error");
}
})
.catch((err) => {
console.error('Error al obtener el carrito:', err);
});
}