Hide refund button if order is not eligible for refund #4789
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #3845
Description
This PR removes the
Issue Refundbutton from the Order Details screen if there's actually no refund to be done. This also fits with how the Android version works.Changes
I have added an additional
isEligibleForRefundcheck to the Order Details data source. This checks if the currentorder.totalis positive. If theorder.totalis positive then the check will pass as there's something to be refunded, and we can load the cell for the refund button on this view.Why use
order.totalfor this check? This contains what a customer has effectively paid and sets the maximum that can be refunded, with coupons, shipping, fees, and taxes taken into consideration.0>00because negative pricesEdge Case: Refunding payment gateway fees:
At the moment I left the option to see the Refund Button if there's fees in the order, so when we have the case
order.total = 0 && order.fees > 0it will show the refund button, this is in consonance with how works in core: The button appears but is only possible to refund these fees directly through the payment gateway:I believe we have 2 options here:
Work in progress
order.totalupdated after a partial refund?Testing steps
1 - Create an order where the price of the product(s) is equal to zero. One way to do this would be to add a sale price of zero for a product.
2 - Open the order in the app.
3 - Attempt to issue a refund for the order. The button is not there.
4 - Now try the same with an order where the price of the product is positive.
5 - Attempt to issue a refund for the order. The button will appear.
Update release notes:
RELEASE-NOTES.txtif necessary.