Skip to content

Commit 28a3552

Browse files
authored
Merge pull request #7277 from woocommerce/issue/7207-mark-order-complete-button-iteration
[Order Details] Do not show Mark Order Complete for unpaid orders
2 parents fb5fb2a + b59fe4e commit 28a3552

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

WooCommerce/Classes/ViewModels/Order Details/OrderDetailsDataSource.swift

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ final class OrderDetailsDataSource: NSObject {
2424
///
2525
private(set) var sections = [Section]()
2626

27-
/// Is this order processing?
27+
/// Is this order processing? Payment received (paid). The order is awaiting fulfillment.
2828
///
29-
private var isProcessingPayment: Bool {
30-
return order.status == OrderStatusEnum.processing
29+
private var isProcessingStatus: Bool {
30+
order.status == OrderStatusEnum.processing
3131
}
3232

3333
/// Is this order fully refunded?
@@ -1025,21 +1025,22 @@ extension OrderDetailsDataSource {
10251025

10261026
var rows: [Row] = Array(repeating: .aggregateOrderItem, count: aggregateOrderItemCount)
10271027

1028-
if shouldShowShippingLabelCreation {
1028+
switch (shouldShowShippingLabelCreation, isProcessingStatus, isRefundedStatus) {
1029+
case (true, false, false):
1030+
// Order completed and eligible for shipping label creation:
10291031
rows.append(.shippingLabelCreateButton)
1030-
}
1031-
1032-
if isProcessingPayment {
1033-
if shouldShowShippingLabelCreation {
1034-
rows.append(.markCompleteButton(style: .secondary, showsBottomSpacing: false))
1035-
rows.append(.shippingLabelCreationInfo(showsSeparator: false))
1036-
} else {
1037-
rows.append(.markCompleteButton(style: .primary, showsBottomSpacing: true))
1038-
}
1039-
} else if isRefundedStatus == false {
1040-
if shouldShowShippingLabelCreation {
1041-
rows.append(.shippingLabelCreationInfo(showsSeparator: true))
1042-
}
1032+
rows.append(.shippingLabelCreationInfo(showsSeparator: false))
1033+
case (true, true, false):
1034+
// Order processing shippable:
1035+
rows.append(.shippingLabelCreateButton)
1036+
rows.append(.markCompleteButton(style: .secondary, showsBottomSpacing: false))
1037+
rows.append(.shippingLabelCreationInfo(showsSeparator: false))
1038+
case (false, true, false):
1039+
// Order processing digital:
1040+
rows.append(.markCompleteButton(style: .primary, showsBottomSpacing: true))
1041+
default:
1042+
// Other cases
1043+
break
10431044
}
10441045

10451046
if rows.count == 0 {

WooCommerce/WooCommerceTests/ViewRelated/Orders/Order Details/OrderDetailsDataSourceTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ final class OrderDetailsDataSourceTests: XCTestCase {
293293

294294
func test_create_shipping_label_button_is_not_visible_when_order_is_eligible_for_payment() throws {
295295
// Given
296-
let order = makeOrder().copy(needsPayment: true, status: .processing, total: "100")
296+
let order = makeOrder().copy(needsPayment: true, status: .pending)
297297
let dataSource = OrderDetailsDataSource(order: order, storageManager: storageManager, cardPresentPaymentsConfiguration: Mocks.configuration)
298298
dataSource.isEligibleForShippingLabelCreation = true
299299

@@ -461,7 +461,7 @@ final class OrderDetailsDataSourceTests: XCTestCase {
461461
}
462462
}
463463

464-
func test_morel_button_is_not_visible_in_product_section_for_cash_on_delivery_order() throws {
464+
func test_more_button_is_not_visible_in_product_section_for_cash_on_delivery_order() throws {
465465
// Given
466466
let order = makeOrder().copy(status: .processing, datePaid: .some(nil), total: "100", paymentMethodID: "cod")
467467
let dataSource = OrderDetailsDataSource(order: order, storageManager: storageManager, cardPresentPaymentsConfiguration: Mocks.configuration)

0 commit comments

Comments
 (0)