Skip to content

Conversation

@jaclync
Copy link
Contributor

@jaclync jaclync commented Aug 29, 2025

For WOOMOB-1017

Just one review is required.

  • @jaclync registers Tracks event after approval

Description

This PR enhanced the POS cash payment UX to match Android with updated analytics tracking. The cash payment input field is now pre-filled with the order total with keyboard focused for easy replacement when merchants start typing. The payment button state is properly managed based on the entered amount and loading state.

The changes remove the validation error message since the button state now provides clear visual feedback about payment readiness. Added test coverage for the currency parsing functionality to ensure robust handling of various input formats.

Steps to reproduce

Notes:

  • When exiting the cash payment then entering again, the previous input is shown. This is a pre-existing behavior.
  • The mentioned Android behavior "selects" the input text field where the selected text has a background color, but I don't think our text field currently supports this selected state (I couldn't manually select the text to see a different background color either). Please let me know if you think this is an important visual cue, I will look into the selected state support for the shared FormattableAmountTextField component separately.
  1. Open the POS and add items to the cart
  2. Navigate to checkout and tap on "Cash payment" button --> checkout_cash_payment_tapped should be tracked
  3. Verify the total amount is pre-filled and the keyboard is focused
  4. Start typing and verify the pre-filled amount is replaced. Also verify the button is disabled unless the amount is equal or higher than total
  5. Turn on airplane mode and tap on "Mark as complete" - verify cash_payment_tapped and cash_payment_failed are tracked
  6. Turn off airplane mode and tap on "Mark as complete" - verify cash_payment_tapped and cash_collect_payment_success are tracked

Testing information

I tested on iPad Pro 11in 3rd generation, iOS 18.5.

Screenshots

ScreenRecording_08-29-2025.16-07-20_1.MP4

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

…the merchant taps on cash payment from the checkout screen. Move the existing `cash_payment_tapped` event to be tracked when marking cash payment as completed.
…te button enabled state based on input & loading state, and remove validation error.
@dangermattic
Copy link
Collaborator

dangermattic commented Aug 29, 2025

1 Warning
⚠️ This PR is assigned to the milestone 23.2. 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.
1 Message
📖

This PR contains changes to Tracks-related logic. Please ensure (author and reviewer) the following are completed:

  • The tracks events must be validated in the Tracks system.
  • Verify the internal Tracks spreadsheet has also been updated.
  • Please consider registering any new events.
  • The PR must be assigned the category: tracks label.

Generated by 🚫 Danger

@jaclync jaclync changed the title Improve cash payment UX and add analytics tracking POS: improve cash payment UX and update analytics tracking Aug 29, 2025
@jaclync jaclync changed the title POS: improve cash payment UX and update analytics tracking POS cash payment: prefill order amount and update analytics tracking Aug 29, 2025
@jaclync jaclync added the type: enhancement A request for an enhancement. label Aug 29, 2025
@jaclync jaclync added this to the 23.2 milestone Aug 29, 2025
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Aug 29, 2025

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

App NameWooCommerce iOS Prototype
Build Numberpr16058-15e4a27
Version23.1
Bundle IDcom.automattic.alpha.woocommerce
Commit15e4a27
Installation URL1ke869f0hkh60
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@jaclync jaclync added the category: tracks Related to analytics, including Tracks Events. label Aug 29, 2025
@iamgabrielma iamgabrielma self-assigned this Sep 1, 2025
Copy link
Contributor

@iamgabrielma iamgabrielma left a comment

Choose a reason for hiding this comment

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

LGTM! Works well, thanks for adding the additional test cases! 🚢

Copy link
Contributor

Choose a reason for hiding this comment

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

Since we're updating this file and testing the cash payment, we could also update the warnings for iOS17 in lines 65 and 108 regarding onChange deprecation 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, fixed in 0dff142. Hopefully we can reset build warnings to 0 and new warnings are detected in CI in the near future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Btw @iamgabrielma while checking your PR #16002 from the latest merge conflicts, the release notes entry seemed to get into 23.1 instead of 23.2. Not sure what impact it has though, maybe just for Peacock beta testing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, appreciated, I did move them here then it seems messed it up when merging trunk into the branch. Thanks, I'll address it 🙇

guard validateAmountOnSubmit() else {
return
}
ServiceLocator.analytics.track(.pointOfSaleCashPaymentTapped)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not necessarily for this PR, but I wonder if we should expose the analytics prop in PointOfSaleAggregateModel, so the POS Views that depend on it can use this dependency for analytics, rather than relying on calling the shared instance of service locator. Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When reviewing Povilas' POS modularization PRs in the last HACK Week, he updated all the ServiceLocator analytics usage with an Analytics environment variable from the top level view for all POS views to access. I hope his work gets merged in soon.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I'll bring some of these things to the trunk, without the POS module itself, so it could be used within the code now.

return false
}
return true
return inputDecimal >= orderDecimal && !isLoading
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 don't find this function specially readable, perhaps just by switching the order a bit and extracting logic from the guard makes it clearer? Could be entirely personal so feel free to ignore (untested!):

    func isPaymentButtonEnabled(orderTotal: String,
                                textFieldAmountInput: String,
                                isLoading: Bool) -> Bool {
        if isLoading { return false }

        let sanitizedInput = textFieldAmountInput.isNotEmpty ? textFieldAmountInput : "0"

        guard let orderDecimal = parseCurrency(orderTotal),
              let inputDecimal = parseCurrency(sanitizedInput) else {
            return false
        }

        return inputDecimal >= orderDecimal
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for suggesting for better readability, updated in 7c576c0.

@jaclync
Copy link
Contributor Author

jaclync commented Sep 4, 2025

Thanks for the review! I responded to the comments and registered/updated the affected Tracks events. Merging shortly.

@jaclync jaclync enabled auto-merge September 4, 2025 03:12
@jaclync jaclync merged commit 72c3a98 into trunk Sep 4, 2025
14 checks passed
@jaclync jaclync deleted the backlog/WOOMOB-1017-cash-payment-changes branch September 4, 2025 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: tracks Related to analytics, including Tracks Events. type: enhancement A request for an enhancement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants