Skip to content

Commit 4550ecc

Browse files
committed
Order details also needs unsupported order statuses handled
1 parent 9124bbe commit 4550ecc

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

WooCommerce/Classes/ViewRelated/Orders/Cells/SummaryTableViewCell.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,18 @@ final class SummaryTableViewCell: UITableViewCell {
5151

5252
/// Displays the specified OrderStatus, and applies the right Label Style
5353
///
54-
func display(orderStatus: OrderStatus) {
55-
paymentStatusLabel.text = orderStatus.name
56-
paymentStatusLabel.applyStyle(for: orderStatus.status)
54+
func display(viewModel: OrderDetailsViewModel) {
55+
if let orderStatus = viewModel.orderStatus {
56+
paymentStatusLabel.applyStyle(for: orderStatus.status)
57+
paymentStatusLabel.text = orderStatus.name
58+
} else {
59+
// There are unsupported extensions with even more statuses available.
60+
// So let's use the order.statusKey to display those as slugs.
61+
let statusKey = viewModel.order.statusKey
62+
let statusEnum = OrderStatusEnum(rawValue: statusKey)
63+
paymentStatusLabel.applyStyle(for: statusEnum)
64+
paymentStatusLabel.text = viewModel.order.statusKey
65+
}
5766
}
5867

5968

WooCommerce/Classes/ViewRelated/Orders/OrderDetailsViewController.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,9 +601,7 @@ private extension OrderDetailsViewController {
601601
self?.displayOrderStatusList()
602602
}
603603

604-
if let orderStatus = viewModel.orderStatus {
605-
cell.display(orderStatus: orderStatus)
606-
}
604+
cell.display(viewModel: viewModel)
607605
}
608606
}
609607

0 commit comments

Comments
 (0)