Plugin Author
ndeet
(@ndeet)
Hey there,
do I need the Pro version to try to reproduce the problem or does this work with the free version too? It’s the extension from WPSwings, right?
Yes, I’m using the “Points and Rewards for WooCommerce Pro” plugin from WPSwings. Since it’s the Pro version, I’m not sure whether the issue also exists in the free version or not.
Plugin Author
ndeet
(@ndeet)
Hey there,
I tried to reproduce but it works for me as expected. When I apply points it creates one order with the discounted price and the BTCPay invoice also has the discounted price. I tried with modal overlay and normal redirect: https://streamable.com/l7v78r (video available for 2 days)
Any more information you can share on how I might be able to reproduce your problem? Are you sure no other plugin (or custom code) is interefering with checkout causing this problem?
<span style=”font-size: inherit;”>Hi,</span>
Thank you for checking this and for sharing the video — that really helped.
I revisited the issue on my side and was able to identify the cause. It looks like the problem was related to the modal checkout script. I made a small change in the modalCheckout.js file, and after that adjustment, the flow is now working correctly for me as well.
The fix is a single line added in modalCheckout.js — add .off() before .on() to prevent duplicate handler attachment:
File: btcpay-greenfield-for-woocommerce/assets/js/frontend/modalCheckout.js (line 191)
if (selected_gateway.startsWith(‘btcpaygf_’)) {
// Remove any existing handler first to prevent duplicates.
checkout_form.off(‘checkout_place_order’, submitOrder);
// Bind our custom event handler to the checkout button.
checkout_form.on(‘checkout_place_order’, submitOrder);
}
Now, when applying points:
The order is created with the correct discounted price
The BTCPay invoice also reflects the discounted amount properly
Both modal overlay and redirect checkout are functioning as expected
So it seems the issue was likely due to a script conflict or how the modal was handling the updated totals during checkout.
At this point, everything is working fine on my end. I’ll continue to monitor it, but it looks resolved after this fix.
Really appreciate your support on this!
Best regards,
Plugin Author
ndeet
(@ndeet)
Hey! Thanks for your feedback. As you mention the modalCheckout.js file, it means you still use legacy checkout (not checkout blocks) on your site?
Anyway, I digged a bit deeper into the event handler and it seems that the on() handler does indeed register the same event multiple times and does not deduplicate it like addEventListener
Thanks, will test and add to next release.
Hi,
Yes, that’s correct — I’m currently using the legacy checkout (not checkout blocks), so the issue was happening within that flow.
That makes sense regarding the event handler. Your observation about the on() handler registering the same event multiple times explains the behavior I was seeing. After adjusting the modalcheckout.js handling on my side, it started working as expected.
Really appreciate you digging into this and confirming the root cause. Glad to hear it will be included in the next release — that should help avoid similar issues going forward.
Thanks again for the support and quick follow-up!
Best regards,
Plugin Author
ndeet
(@ndeet)
Hi, thank you very much for helping debug the issue. I took a slightly different approach than in your fix but it should work same way. Would be great if you could confirm it working for you now with version 2.7.4.