Skip to content

Commit

Permalink
Add support for restoring deleted orders to the example app
Browse files Browse the repository at this point in the history
  • Loading branch information
hichamboushaba committed Sep 20, 2024
1 parent 4d0f0c3 commit 1f7add4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,33 @@ class WooOrdersFragment : StoreSelectingFragment(), WCAddOrderShipmentTrackingDi
}
}

restoreOrder.setOnClickListener {
selectedSite?.let { site ->
lifecycleScope.launch {
val orderId = showSingleLineDialog(
activity = requireActivity(),
message = "Please enter the order id",
isNumeric = true
)?.toLongOrNull()

if (orderId == null) {
prependToLog("Please enter a valid order id")
return@launch
}

val result = orderUpdateStore.restoreDeletedOrder(site, orderId)
if (result.isError) {
prependToLog(
"Restoring order failed, " +
"error ${result.error.type} ${result.error.message}"
)
} else {
prependToLog("Order $orderId has been restored succesfully")
}
}
}
}

fetchOrderAttribution.setOnClickListener {
selectedSite?.let { site ->
showSingleLineDialog(activity, "Enter the remoteOrderId of order to fetch:") { editText ->
Expand Down
7 changes: 7 additions & 0 deletions example/src/main/res/layout/fragment_woo_orders.xml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@
android:enabled="false"
android:text="Delete an order" />

<Button
android:id="@+id/restore_order"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:text="Restore a trashed order" />

<Button
android:id="@+id/fetch_order_attribution"
android:layout_width="match_parent"
Expand Down

0 comments on commit 1f7add4

Please sign in to comment.