Skip to content

Commit 4bfc20a

Browse files
authored
Orders: Add web checkout and wp-admin as options to order sales channel filter (#16228)
2 parents 32e3121 + 089c457 commit 4bfc20a

File tree

13 files changed

+166
-24
lines changed

13 files changed

+166
-24
lines changed

Modules/Sources/NetworkingCore/Model/SalesChannel.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@ import Foundation
22

33
public enum SalesChannel {
44
case pointOfSale
5+
case webCheckout
6+
case wpAdmin
57
}
68

79
extension SalesChannel: RawRepresentable {
810
public init?(rawValue: String) {
911
switch rawValue {
1012
case "pos-rest-api":
1113
self = .pointOfSale
14+
case "checkout", "store-api":
15+
self = .webCheckout
16+
case "admin":
17+
self = .wpAdmin
1218
default:
1319
return nil
1420
}
@@ -18,6 +24,10 @@ extension SalesChannel: RawRepresentable {
1824
switch self {
1925
case .pointOfSale:
2026
return description
27+
case .webCheckout:
28+
return description
29+
case .wpAdmin:
30+
return description
2131
}
2232
}
2333

@@ -27,6 +37,14 @@ extension SalesChannel: RawRepresentable {
2737
return NSLocalizedString("salesChannel.pos.description",
2838
value: "POS",
2939
comment: "The acronym for 'Point of Sale'.")
40+
case .webCheckout:
41+
return NSLocalizedString("salesChannel.webCheckout.description",
42+
value: "Web Checkout",
43+
comment: "Orders created through web checkout.")
44+
case .wpAdmin:
45+
return NSLocalizedString("salesChannel.wpAdmin.description",
46+
value: "WP-Admin",
47+
comment: "Orders created through WordPress admin interface.")
3048
}
3149
}
3250
}

Modules/Sources/Yosemite/Model/Model.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public typealias OrderStatsV4Totals = Networking.OrderStatsV4Totals
8484
public typealias OrderStatus = Networking.OrderStatus
8585
public typealias OrderUpdateField = Networking.OrdersRemote.UpdateOrderField
8686
public typealias OrderCreateField = Networking.OrdersRemote.CreateOrderField
87+
public typealias OrderSalesChannel = Networking.SalesChannel
8788
public typealias PaymentGateway = Networking.PaymentGateway
8889
public typealias PaymentGatewayAccount = Networking.PaymentGatewayAccount
8990
public typealias Product = Networking.Product

Modules/Sources/Yosemite/Model/Orders/SalesChannelFilter.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ import Foundation
44
///
55
public enum SalesChannelFilter: String, Codable, Hashable {
66
case pointOfSale
7+
case webCheckout
8+
case wpAdmin
79
case any
810
}

Modules/Sources/Yosemite/Model/Orders/StoredOrderSettings.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public struct StoredOrderSettings: Codable, Equatable {
4242
if customerFilter != nil {
4343
total += 1
4444
}
45-
if let salesChannelFilter = salesChannelFilter, case .pointOfSale = salesChannelFilter {
45+
if let salesChannelFilter = salesChannelFilter, salesChannelFilter != .any {
4646
total += 1
4747
}
4848

RELEASE-NOTES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
-----
66
- [internal] POS code was moved to its own module, including POS specific color and image assets. [https://github.com/woocommerce/woocommerce-ios/pull/16176]
77
- [*] Fix Create Coupon screen scrolling issue. [https://github.com/woocommerce/woocommerce-ios/pull/16218]
8-
8+
- [*] Order list: Allow filtering of Web, Point of Sale, and WP-Admin orders. [https://github.com/woocommerce/woocommerce-ios/pull/16228]
99

1010
23.4
1111
-----

WooCommerce/Classes/Analytics/WooAnalyticsEvent+OrdersListFilter.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ fileprivate extension SalesChannelFilter {
3030
switch self {
3131
case .pointOfSale:
3232
return "pos"
33+
case .webCheckout:
34+
return "checkout"
35+
case .wpAdmin:
36+
return "admin"
3337
case .any:
3438
return nil
3539
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ struct OrderListCellViewModel {
6666
return order.status.localizedName
6767
}
6868

69-
/// Textual representation of the sales channel
69+
/// Sales channel
7070
///
71-
var salesChannel: String? {
72-
order.salesChannel?.description
71+
var salesChannel: OrderSalesChannel? {
72+
order.salesChannel
7373
}
7474

7575
/// The localized unabbreviated total for a given order item, which includes the currency.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ final class OrderTableViewCell: UITableViewCell & SearchResultCell {
6363
paymentStatusLabel.text = viewModel.statusString
6464

6565
if ServiceLocator.featureFlagService.isFeatureFlagEnabled(.pointOfSaleOrdersi1),
66-
let salesChannel = viewModel.salesChannel {
66+
let salesChannel = viewModel.salesChannel, salesChannel == .pointOfSale {
6767
salesChannelLabel.isHidden = false
6868
salesChannelLabel.applySalesChannelStyle()
69-
salesChannelLabel.text = salesChannel
69+
salesChannelLabel.text = salesChannel.description
7070
} else {
7171
salesChannelLabel.isHidden = true
7272
}

WooCommerce/Classes/ViewRelated/Orders/Order Filters/FilterOrderListViewModel.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ extension FilterOrderListViewModel.OrderListFilter {
268268
listSelectorConfig: .customer(siteID: siteID),
269269
selectedValue: filters.customer)
270270
case .salesChannel:
271-
let salesChannelOptions: [SalesChannelFilter] = [.any, .pointOfSale]
271+
let salesChannelOptions: [SalesChannelFilter] = [.any, .pointOfSale, .webCheckout, .wpAdmin]
272272
return FilterTypeViewModel(title: title,
273273
listSelectorConfig: .staticOptions(options: salesChannelOptions),
274274
selectedValue: filters.salesChannel)
@@ -387,6 +387,16 @@ extension SalesChannelFilter: FilterType {
387387
"salesChannelFilter.row.pos.description",
388388
value: "Point of Sale",
389389
comment: "Description for the Sales channel filter option, when selecting 'Point of Sale' orders")
390+
case .webCheckout:
391+
return NSLocalizedString(
392+
"salesChannelFilter.row.webCheckout.description",
393+
value: "Web Checkout",
394+
comment: "Description for the Sales channel filter option, when selecting 'Web Checkout' orders")
395+
case .wpAdmin:
396+
return NSLocalizedString(
397+
"salesChannelFilter.row.wpAdmin.description",
398+
value: "WP-Admin",
399+
comment: "Description for the Sales channel filter option, when selecting 'WP-Admin' orders")
390400
case .any:
391401
return NSLocalizedString(
392402
"salesChannelFilter.row.any.description",
@@ -397,7 +407,7 @@ extension SalesChannelFilter: FilterType {
397407

398408
var isActive: Bool {
399409
switch self {
400-
case .pointOfSale:
410+
case .pointOfSale, .webCheckout, .wpAdmin:
401411
return true
402412
case .any:
403413
return false

WooCommerce/Classes/ViewRelated/Orders/OrderListSyncActionUseCase.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,18 @@ struct OrderListSyncActionUseCase {
6363
let endDate = filters?.dateRange?.computedEndDate
6464
let productID = filters?.product?.id
6565
let customerID = filters?.customer?.id
66-
let createdVia = filters?.salesChannel == .pointOfSale ? "pos-rest-api" : nil
66+
let createdVia: String? = {
67+
switch filters?.salesChannel {
68+
case .pointOfSale:
69+
return "pos-rest-api"
70+
case .webCheckout:
71+
return "checkout,store-api"
72+
case .wpAdmin:
73+
return "admin"
74+
case .any, .none:
75+
return nil
76+
}
77+
}()
6778

6879
if pageNumber == Defaults.pageFirstIndex {
6980
let deleteAllBeforeSaving = reason == SyncReason.pullToRefresh || reason == SyncReason.newFiltersApplied

0 commit comments

Comments
 (0)