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

[Woo POS][Cash & Receipts] Validate empty cash user input as zero #14954

Merged

Conversation

iamgabrielma
Copy link
Contributor

@iamgabrielma iamgabrielma commented Jan 23, 2025

Ref: pdfdoF-6fr#comment-7372-p2

Description

This PR updates the submit validation logic when processing cash, so if an empty textfield is submitted for validation, we assume that it's zero. This is done to handle 0-value carts with free products without the user having to specifically type "0" in the textfield.

Testing information

  • Switch .acceptCashForPointOfSale on
  • Process a POS transaction with a $0-cart value, select cash payment
  • Tap the "Mark as Complete" button without typing anything in the textfield
  • Observe that the transaction is processed normally
Screen.Recording.2025-01-23.at.08.25.37.mov

Receipts and the rest of the flow works as before, the only difference is we remove the need to type down 0 in the textfield.

Screenshot 2025-01-23 at 08 49 24
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Reviewer (or Author, in the case of optional code reviews):

Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement:

  • The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
  • Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
  • Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on all devices (phone/tablet) and no regressions are added.

@iamgabrielma iamgabrielma added type: task An internally driven task. feature: POS labels Jan 23, 2025
@iamgabrielma iamgabrielma added this to the 21.5 milestone Jan 23, 2025
@dangermattic
Copy link
Collaborator

1 Warning
⚠️ This PR is assigned to the milestone 21.5. This milestone is due in less than 2 days.
Please make sure to get it merged by then or assign it to a milestone with a later deadline.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Jan 23, 2025

WooCommerce iOS📲 You can test the changes from this Pull Request in WooCommerce iOS by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS WooCommerce iOS
Build Numberpr14954-29b3990
Version21.4
Bundle IDcom.automattic.alpha.woocommerce
Commit29b3990
App Center BuildWooCommerce - Prototype Builds #12659
Automatticians: You can use our internal self-serve MC tool to give yourself access to App Center if needed.

@joshheald joshheald self-assigned this Jan 23, 2025
Copy link
Contributor

@joshheald joshheald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well, one small stylistic suggestion

@@ -36,8 +36,10 @@ final class CollectCashViewHelper {
func validateAmountOnSubmit(orderTotal: String,
textFieldAmountInput: String,
onError: (String) -> Void) -> Bool {
let userInput = textFieldAmountInput.isEmpty ? "0" : textFieldAmountInput
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'd do this the other way around – it's easier to understand if the common case comes first (by checking .isNotEmpty,) then the fallback.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, updated: 29b3990

@iamgabrielma iamgabrielma merged commit d3a6ea1 into trunk Jan 23, 2025
12 checks passed
@iamgabrielma iamgabrielma deleted the task/pos-add-extra-cash-validation-when-cart-is-zero branch January 23, 2025 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: POS type: task An internally driven task.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants