-
-
Notifications
You must be signed in to change notification settings - Fork 707
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 part 2 #11135
Vouchers part 2 #11135
Conversation
This shouldn't be in column 'closed', should it? |
When a voucher is applied to an order with tax excluded from the price, two voucher adjustment are created, one for the voucher and one for the tax component. I fixed the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re added my review from the old PR.
This applies to cases where an order contains items with zero price or where applied vouchers have reduced the order's total to zero.
I've dropped that commit for now. I think there's probably various changes that need to be made around tax adjustments on vouchers but the scope of this PR is already quite substantial. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic, looks like a big re-arrange that solves some problems and helps us move forward with vouchers.
I noticed a couple of additions without associated specs that I thought seemed important. If we don't add them now, can they be included in the next round?
Also I have several questions/comments soz
But overall I think this is good to proceed as-is (if the specs are included in the next round).
%strong= last_payment_method(order)&.name | ||
%p.text-small.text-skinny.pre-line.word-wrap | ||
%em= last_payment_method(order)&.description | ||
- if (order_payment_method = last_payment_method(order)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good to see the helper method result being cached instead of calling twice, but I would avoid that in the view. Also would avoid using assignment in a condition.
Still, this is better than it was before.
Is that being addressed anywhere ? are you looking at it ? |
PS sorry one more question, do we need to update the email confirmation template too? |
As the vouchers use adjustment, we get that for free, adjustments will show on the email confirmation. |
Actually i was thinking, since we're updating the confirmation screen to show "No payment required", this might also be relevant for the confirmation email. Upon looking, I think it is relevant. The So.. can we add this in a follow-up PR? (I don't want to stall this one any longer!) |
Co-authored-by: Gaetan Craig-Riou <gaetan.riou@gmail.com> Co-authored-by: Gaetan Craig-Riou <40413322+rioug@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about the usage of dup
, so am wondering if we can avoid that?
Also I've applied Gaetan's suggestion.
I collated some follow up notes and added to the description of this PR too.
app/models/spree/order.rb
Outdated
@@ -222,7 +222,7 @@ def payment_required? | |||
# There are items present in the order, but either the items have zero price, | |||
# or the order's total has been modified (maybe discounted) to zero. | |||
def zero_priced_order? | |||
valid? && line_items.count.positive? && total.zero? | |||
dup.valid? && line_items.count.positive? && total.zero? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I've not seen that done before. It doesn't seem like best practise, but I can't think of a good alternative.
Why do we need to check validity? Is this important for all uses of zero_priced_order?
Shouldn't the controller check the validity before proceeding anyway? Or is there a specific thing we can re-check here without using valid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, why do we need this method as distinct from payment_required?
I'll attempt to answer..
It seems that the zero_priced_order passes through the payment state, and records a zero payment. But subscriptions are a (weird) case where we want to treat it as a complete order without properly completing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are multiple places where this method will be called from (not just one controller), and calling valid?
flushes all errors on the current order object and re-checks them, which is not desirable in some situations (custom non-ActiveRecord errors added during checkout being a prime example).
I'll just drop the valid?
check, maybe it's not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specs pass... so I guess it's not 🤞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good !
Ok, continuing: Fixed: a snail is not triggered after visiting the cart page and resuming checkout. However, when resuming checkout, the user always seems to be redirected to the Fixed: I could not reproduce the issue, it seems to have been related orders with Fixed: Fixed: Visiting the
Fixed: it's possible to checkout now for orders with total = 0 (without adding a voucher): Order confirmation: Summary Merging 💪 |
What? Why?
Closes #10857, #10865, #10869, #10855 and #10787
Brings in a few changes to the way vouchers are applied at the checkout.
<form>
so it can submit to a separate controller as mentioned here 10432 vouchers bare minimum checkout #10587 (comment)create
action in the voucher controller (alongside the existingdelete
action which is already there)0.0
gets added to the order in this case and the order can be completed successfully.What should we test?
If an order is valid but doesn't require payment then... it doesn't require payment. Adding a voucher that brings the order total to zero hides the payment method options and lets the user know that no payment is required. The order can be completed successfully.
#10857, #10865, #10869, #10855 and #10787 should all be fixed/closed.
Release notes
Changelog Category: Technical changes
The title of the pull request will be included in the release notes.
Follow up required