Hi Community,
I have some code that works fine as a pop up window if someone trys to order under X amount, it is as follows:
// For full API documentation, including code examples, visit https://wix.to/94BuAAs
import wixWindow from 'wix-window'
import {getTotal} from 'backend/MinQuantity.jsw';
import wixLocation from 'wix-location';
$w.onReady(function () {
//TODO: write your page related code here...
getTotal().then(function(product) {
let total = product.totals.total;
if (total<500) {
wixWindow.openLightbox("PPE")
}
});
});
However, if the customer adjusts the amount of items, and the ‘total’, as referenced above, is still under the £500 threshold the pop up is not activated.
Is there a way to refresh the entire page when the ‘totat’ changes?
Thanks in advance.
Hi there,
There are multiple ways to go about refreshing a page, however, choosing which method will depend on your current set up. What’s the reasoning for refreshing your page? Can you elaborate a little more on your current flow?
The simplest way to refresh to your page would be by utilizing the wixLocation.to() API with the URL of the page you’d want to refresh after the condition that changes your total.
However, keep in mind when refreshing your page with this method it may affect performance since you’ll need to run your queries once again.
You may want to just refresh certain elements or specific parts of your data.
If possible, please provide a link to your site, so we can take a further look.
Best regards,
Miguel
Good afternoon again Miguel,
You seen to be helping me a lot at the moment and for that I am very grateful!
The reasoning for refreshing the page - shopping cart page - is because the above code works swimmingly when the user adds a product to the basket and first enters the shopping cart.
A lightbox appears, states they need to spend a minimum of X - £500 in the above code.
All operates well until then.
IF the user adjusts the quantity of the product while on the shopping cart page, and the total still does not exceed the threshold - £500 - another popup/ lightbox does not appear.
So that is what I am wrestling with. I am open to suggestions.
Link to page: https://theobowen.wixsite.com/mysite/cart-page?appSectionParams=%7B%22origin%22%3A%22cart-popup%22%7D