Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class WooPosOrdersDataSource @Inject constructor(
page = page,
orderBy = OrderBy.DATE,
sortOrder = OrderRestClient.SortOrder.DESCENDING,
statusFilter = null,
statusFilter = "pending,processing,on-hold,completed,cancelled,refunded,failed",
Copy link
Contributor

Choose a reason for hiding this comment

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

Keep in mind that this approach won’t work if there are any custom statuses or if a new status is introduced. Because of that reason, Povilas decided not to filter out this way the checkout-draft status.

Also, can it be that auto-draft not returned by default in the new versions of Woo? I don't see them. I checked the source code with Ai and it says:

Copilot said: Auto-draft orders are excluded because WooCommerce registers
Auto-draft orders are excluded because WooCommerce registers that post‑status as non‑public (not exposed to REST) and the DraftOrders code/hooks explicitly remove draft/auto‑draft from order queries, so the orders list API omits them by default.

Copy link
Contributor

Choose a reason for hiding this comment

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

You are onto something, notice this comment:

 // Draft orders are not returned from the API. We need to re-fetch order list from the API
// when the order is new or its status changed from draft to another status.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay. I just tested on WooCommerce 10.2.0 and auto-drafts are not returned there. So this is apparently a change in the behavior of the API! I think we'll need to track whether it's intentional or not and either fix it or update the apps (not just POS, but even Order list).

createdVia = "pos-rest-api",
searchQuery = searchQuery
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class WooPosOrdersDataSourceTest {
page = 1,
orderBy = OrderRestClient.OrderBy.DATE,
sortOrder = OrderRestClient.SortOrder.DESCENDING,
statusFilter = null,
statusFilter = "pending,processing,on-hold,completed,cancelled,refunded,failed",
createdVia = "pos-rest-api",
searchQuery = query
)
Expand All @@ -240,7 +240,7 @@ class WooPosOrdersDataSourceTest {
page = 1,
orderBy = OrderRestClient.OrderBy.DATE,
sortOrder = OrderRestClient.SortOrder.DESCENDING,
statusFilter = null,
statusFilter = "pending,processing,on-hold,completed,cancelled,refunded,failed",
createdVia = "pos-rest-api",
searchQuery = query
)
Expand All @@ -265,7 +265,7 @@ class WooPosOrdersDataSourceTest {
page = 1,
orderBy = OrderRestClient.OrderBy.DATE,
sortOrder = OrderRestClient.SortOrder.DESCENDING,
statusFilter = null,
statusFilter = "pending,processing,on-hold,completed,cancelled,refunded,failed",
createdVia = "pos-rest-api",
searchQuery = query
)
Expand Down Expand Up @@ -295,7 +295,7 @@ class WooPosOrdersDataSourceTest {
page = 1,
orderBy = OrderRestClient.OrderBy.DATE,
sortOrder = OrderRestClient.SortOrder.DESCENDING,
statusFilter = null,
statusFilter = "pending,processing,on-hold,completed,cancelled,refunded,failed",
createdVia = "pos-rest-api",
searchQuery = query
)
Expand Down Expand Up @@ -419,7 +419,7 @@ class WooPosOrdersDataSourceTest {
page = 1,
orderBy = OrderRestClient.OrderBy.DATE,
sortOrder = OrderRestClient.SortOrder.DESCENDING,
statusFilter = null,
statusFilter = "pending,processing,on-hold,completed,cancelled,refunded,failed",
createdVia = "pos-rest-api",
searchQuery = query
)
Expand All @@ -445,7 +445,7 @@ class WooPosOrdersDataSourceTest {
page = 2,
orderBy = OrderRestClient.OrderBy.DATE,
sortOrder = OrderRestClient.SortOrder.DESCENDING,
statusFilter = null,
statusFilter = "pending,processing,on-hold,completed,cancelled,refunded,failed",
createdVia = "pos-rest-api",
searchQuery = query
)
Expand All @@ -464,7 +464,7 @@ class WooPosOrdersDataSourceTest {
page = 2,
orderBy = OrderRestClient.OrderBy.DATE,
sortOrder = OrderRestClient.SortOrder.DESCENDING,
statusFilter = null,
statusFilter = "pending,processing,on-hold,completed,cancelled,refunded,failed",
createdVia = "pos-rest-api",
searchQuery = query
)
Expand Down