Skip to content

Conversation

staskus
Copy link
Contributor

@staskus staskus commented Sep 10, 2025

WOOMOB-1140

Description

Continuation of #16110, to update order list and order details after the receipt is sent:

  • Fetch the order from the API after the receipt is sent
  • In PointOfSaleOrderListController update the order list and the selected order
  • Bonus: Improve POSButtonStyle to add a success state to the button that is shown in POSSendReceiptView when the receipt is successfully sent

Steps to reproduce

  1. Open POS -> Menu -> Orders
  2. Select a completed order
  3. Select "Email receipt"
  4. Confirm a loading state is shown when the email is being sent
  5. Confirm a success state is shown when the email is sent
  6. Confirm the view is automatically dismissed
  7. Confirm new email details are reflected in the order list and order details views

Testing information

Tested on iPad Air 26.0 simulator

Screenshots

update.details.mov

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

@staskus staskus added this to the 23.3 milestone Sep 10, 2025
@staskus staskus added type: task An internally driven task. feature: POS labels Sep 10, 2025
@staskus staskus force-pushed the woomob-1140-woo-poshistorical-orders-order-details-update-order-details-and-list branch from f54f077 to fef9630 Compare September 10, 2025 12:42
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Sep 10, 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 Numberpr16113-f31edba
Version23.2
Bundle IDcom.automattic.alpha.woocommerce
Commitf31edba
Installation URL3v2fm0le70gs8
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

Base automatically changed from woomob-1140-woo-poshistorical-orders-order-details-email-receipt-action to trunk September 12, 2025 05:55
@iamgabrielma iamgabrielma self-assigned this Sep 15, 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.

Nice! LGTM :shipit:

Some notes, not necessarily for this PR:

  • Should refunded orders display the email receipt button? It does in the app, but not in POS.
  • This seems an edge case: If an order is sent to X email, but then we assign a customer to the order and this happens to have a billing address, it will override it when rendering in order list, but not in order details. Note order 4305 at the top has different emails in each view.
Simulator Screenshot - iPad mini (A17 Pro) - US store - 2025-09-15 at 11 57 38

For this I sent the receipt to X email address, then assigned a customer to the order which had a different email on their billing details.

/// - orderID: ID of the order to load.
/// - Returns: The loaded Order.
/// - Throws: Network or parsing errors.
func loadPOSOrder(siteID: Int64, orderID: Int64) async throws -> Order {
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: This could be an async wrapper for existing loadOrder, right? So no need to define the function specifically for POS orders

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I first reused the existing method, but it's a bit awkward since it uses non-async version of enqueue that returns an optional Data? and optional Error? which requires to set some unknown` error state to make sure all the code paths are covered. Seemed cleaner to create this new async method.

Copy link
Contributor

Choose a reason for hiding this comment

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

Gotcha, sounds good to me! 🕺


// Setup updated order
let orderToUpdate = initialOrders[0]
let updatedOrder = POSOrder(
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if we discussed this previously, or if wasn't worth it due to the small data structures for POS, but do you think we want to make POSOrders and others GeneratedFakeable/Copiable?So we would only need to do things like POSOrder.fake().copy(customerEmail: "[email protected]")

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 advice. Done that 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit regarding test names to use _when_ABC_then_XYZ

struct POSFilledButtonStyle: ButtonStyle {
private let size: POSButtonSize
private let isLoading: Bool
private let state: POSButtonState
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice 💯

@staskus staskus force-pushed the woomob-1140-woo-poshistorical-orders-order-details-update-order-details-and-list branch from fef9630 to f31edba Compare September 15, 2025 11:57
@staskus
Copy link
Contributor Author

staskus commented Sep 15, 2025

@iamgabrielma, thank you for the excellent review!

Should refunded orders display the email receipt button? It does in the app, but not in POS.

I think we should do it. I'll leave it for i2. We need to set a refund template in send_email API method. We also have a bunch of refund-related improvements for order details that we could stack together:

  • Issue Refund action
  • Refunded products in Order Details
  • Email Receipt button for refunded orders

They will make sense as a separate refunds-related update.

This seems an edge case: If an order is sent to X email, but then we assign a customer to the order and this happens to have a billing address, it will override it when rendering in order list, but not in order details. Note order 4305 at the top has different emails in each view.

Good catch! That actually was an issue with how state is persisted in OrderListController where we didn't update selectedOrder when the order list data updated. Fixed that!

@staskus staskus enabled auto-merge September 15, 2025 12:05
@staskus staskus merged commit a6a131f into trunk Sep 15, 2025
14 checks passed
@staskus staskus deleted the woomob-1140-woo-poshistorical-orders-order-details-update-order-details-and-list branch September 15, 2025 12:17
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.

3 participants