Skip to content

Conversation

@joshheald
Copy link
Contributor

@joshheald joshheald commented Nov 17, 2025

Merge after: #16353

Description

This PR ensures that trashed products are removed from POS after an incremental sync.

We already hide them if they're trashed when we do a full sync – because the API doesn't return them for a normal request. However, that works against us if they've been trashed when we do an incremental sync, because the newly-trashed product won't be returned for those requests either.

To resolve that, we do an extra request for any newly trashed products, and include those in the local database. When we've done that, we filter those products from all our queries.

Note that Variations can't be trashed, they just get deleted.

Test Steps

Set up a new product with a GTIN that you can scan with a barcode scanner

  1. Ensure you've done a full sync
  2. Trash a product in WP-Admin
  3. Pull to refresh
  4. Observe that product is no longer shown in the list
  5. Scan the barcode
  6. Observe that a Not found error is shown, same as for deleted products

Search isn't affected by this, as it doesn't use the local catalog yet.

Fully deleted products are still not removed by incremental sync, but will be by the next full sync. Without extensive backend work, this is unavoidable.

Screenshots

This shows:

  1. View a product
  2. Trash it
  3. Pull to refresh
  4. Scroll down – it's gone
  5. Trash another product on the first page
  6. Pull to refresh
  7. Product is gone
  8. Restore product
  9. Pull to refresh
  10. Product is back
trashed.products.mp4

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

joshheald and others added 18 commits November 14, 2025 16:21
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Add tests verifying include_status parameter is correctly added/omitted
- Add test verifying status is included in _fields request parameter
- Update MockPOSCatalogSyncRemote to support includeStatus parameter
- Update test fixtures to include required statusKey field

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
- Add tests verifying both regular and trashed products are fetched
- Add test ensuring same modifiedAfter date is used for both requests
- Add test verifying includeStatus parameter values
- Add tests for combined persistence of regular and trashed products
- Add tests for edge cases (empty trash, only trash updates)
- Enhance MockPOSCatalogSyncRemote to support separate trashed product results

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Replace non-thread-safe array append with actor-based IncludeStatusTracker
to prevent EXC_BAD_ACCESS crash when concurrent requests modify the array.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Add "status": "publish" to product fixtures that were missing the field,
fixing decoding errors in POSCatalogSyncRemoteTests.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Wrap single product objects in {"data": [...]} envelope to match
standard WooCommerce REST API response format expected by tests.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Add statusKey field with default value "publish" to TestProduct struct
to match updated PersistedProduct schema, fixing NOT NULL constraint errors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@joshheald joshheald added this to the 23.8 milestone Nov 17, 2025
@joshheald joshheald added type: task An internally driven task. feature: POS labels Nov 17, 2025
@joshheald joshheald changed the base branch from trunk to issue/woomob-1686-local-catalog-handle-errors-from-order-creation-with November 17, 2025 12:31
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Nov 17, 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 Numberpr16361-6475ea2
Version23.6
Bundle IDcom.automattic.alpha.woocommerce
Commit6475ea2
Installation URL6b4qvp7doejjg
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

The catalog download parser decodes all items as POSProduct first before
filtering by type, so variations also need the status field to avoid
decoding errors.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@joshheald joshheald marked this pull request as ready for review November 17, 2025 13:46
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