Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Vouchers] Errors when/from iterating between /summary and /cart page #10857

Closed
filipefurtad0 opened this issue May 17, 2023 · 1 comment · Fixed by #11002, #11117 or #11135
Closed

[Vouchers] Errors when/from iterating between /summary and /cart page #10857

filipefurtad0 opened this issue May 17, 2023 · 1 comment · Fixed by #11002, #11117 or #11135
Assignees
Labels
priority We focus on this issue right now

Comments

@filipefurtad0
Copy link
Contributor

filipefurtad0 commented May 17, 2023

Description

This is treated as one issue, as it seems to me (I might be wrong) that this is all coming from the same root cause. Also related to #10855

After adding a voucher and while on the confirmation page, the user may opt for returning to either the /cart page (editing quantities, for ex.):

  • If there are no taxes on the order/voucher -> voucher is removed from the order
  • If there are taxes on the order/voucher, and voucher amount > order.total -> snail
  • If there are taxes on the order/voucher, voucher amount <= order.total -> additional parcels will be created for the voucher, on each /summary page visit, till a snail is triggered

Bugsnag
https://app.bugsnag.com/yaycode/openfoodnetwork-uk/errors/6464d03f630d0f000895ebe9?filters[event.since]=30d&filters[error.status]=open&filters[app.release_stage]=staging&event_id=6464d90700bd31520e150000

Expected Behavior

The user should be able to iterate between /summary and the /cart pages.

Actual Behaviour

Iterating between the /cart and /summary pages triggers a snail.

Steps to Reproduce

For all voucher issues: per-requisites are:

  • As super admin - enable the vouchers feature toggle
  • Having a hub with at least one voucher created
  • The hub should have an open shop

An order/line item/customer with no taxes:

  1. As a customer, on the shopfront, add items to the cart and proceed to the /summary step

image

  1. Open the side menu and visit the /cart page.

image

no taxes on the order/voucher

  1. Click Checkout button, to return to the /summary page -> notice the voucher was removed from the order.

image

taxes on the order/voucher, and voucher amount > order.total -> snail

  1. Open the side menu and visit the /cart page. Click Checkout button -> 🐌

image

Animated Gif/Screenshot

image

Workaround

  • returning to the /payment step, and re-adding the voucher
  • If error 500 is triggered, then the user is "stuck" -> only way out is emptying the cart on the /cart page
@rioug
Copy link
Collaborator

rioug commented Jun 5, 2023

I had a quick look at this, I believe it's due to VoucherAdjustmentsService.calculate recalculating the voucher adjustment when it shouldn't. My first though is that we need to check if the voucher_adjustment.state is "closed", if so ignore any calculation.

But then I am pretty sure there are scenarios where it makes sense to recalculate the voucher adjustment (ie, quantity have been changed via /cart page) so we'll have to figure out how to handle that. We can look at what happen to other adjustment when the checkout flow is reset, and do something similar for voucher adjustment, and/or set the existing voucher_adjustment.state to "open" (and maybe update order total ?) so it is calculated again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment