#pinkpanda-ece-shipping
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- pinkpanda7052, 19 hours ago, 30 messages
Hello! Give me a minute to catch up
You mentioned in the previous thread you were going to record a video - do you have that?
Hi, I didn't get around to the video in the end, as the thread got closed. I will say though that yesterday I didn't discover the workaround for making the price more expensive before resolving, and then updating with the correct lower price...
shall I share the handler function with you here? I'm happy to go and record a video now too
but will need a moment to do that
var handleAddressChange = function (event) {
// Do validate and fetch shipping options
return validateAddressAndFetchShippingOptions(event.address, 'delivery').then(function () {
// Address is deliverable (resolve)
if (StripeExpressCheckoutElementsService.isLastValidatedAddressDeliverable()) {
var lastTotalToPay = StripeExpressCheckoutElementsService.getLastTotalToPay();
var totalToPay = StripeExpressCheckoutElementsService.getTotalToPay();
// Total to pay is more expensive than previously (VAT added on for example)
// - Call updateAmount first
if (totalToPay > lastTotalToPay) {
updateAmount();
event.resolve({
lineItems: getLineItems(),
shippingRates: getShippingRates()
});
}
// Total to pay is cheaper than previously (VAT removed for example)
// - Update lineItems first
else {
// updateAmount(); // This does not work because we're trying to set a total "amount" to pay that is less than the total amount of the items (since they are updated on the line below)
event.resolve({
lineItems: getLineItems(),
shippingRates: getShippingRates()
});
// updateAmount(); // This does not update the UI, presumably because it happens AFTER event.resolve
}
}
// Address not deliverable (reject)
else {
event.reject();
}
});
}
Alternatively, if you have a site I can look at that repros the behavior you're welcome to send that over
I'll do the video so that I can try to explain everything as I show it happening
Can this thread be kept open while I do this?
It still doesn't work, but for some reason when setting the cheaper value than what the line items are set to, it isn't failing with an error now...
I was hoping to capture it all on the video
the UI does not update to the lower value so it's not working unless I first set the more expensive price, but that error has gone? Would someone be making updates to it already?
I can see the line items are cheaper than the total displayed in the UI... previously your system was failing with a console error, and this is not happening now
As far as I know we haven't changed anything, but I don't own that feature so I could be wrong
So the current state now is that just updating the lower vaule is still not working?
Yes, as per the screenshot above, you can see line items are £40 but the total is still £48
Just realised I've left my email and phone number for all of the discord channel, so i'll remove that image and repost it...
I was expecting the video to include the issue where we can't set a price lower than the sum of the line items' amounts, but since that seems to have vanished, i'll record the video and skip over mentioning that...
Also real quick - can you share the updateAmount function with me? I see you're calling it in your code block above, but it would help to see what it does
pinkpanda-ece-shipping
var updateAmount = function (newAmount) {
if (isNaN(newAmount)) {
newAmount = StripeExpressCheckoutElementsService.getTotalToPay();
}
StripeExpressCheckoutElementsService.setLastTotalToPay(newAmount);
elements.update({
amount: newAmount
});
console.log('updateAmount() called... elements.update({ amount: '+ newAmount +' })', elements);
}
If newAmount is not provided or is not a number, we'll called getTotalToPay() which is calculated from the basket contents.