Skip to content

Commit ed18c80

Browse files
authored
Merge pull request #6538 from woocommerce/issue/6177-order-feedback-banner
Order Creation: Update feedback banner on Orders tab for Order Creation & Simple Payments
2 parents 8ef9ce3 + 2641076 commit ed18c80

File tree

9 files changed

+71
-68
lines changed

9 files changed

+71
-68
lines changed

WooCommerce/Classes/Analytics/WooAnalyticsEvent.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ extension WooAnalyticsEvent {
7171
case shippingLabelsRelease3 = "shipping_labels_m3"
7272
/// Shown in beta feature banner for order add-ons.
7373
case addOnsI1 = "add-ons_i1"
74-
/// Shown in beta feature banner for simple payments prototype.
75-
case simplePaymentsPrototype = "simple_payments_prototype"
74+
/// Shown in orders banner for order creation release.
75+
case orderCreation = "order_creation"
7676
/// Shown in beta feature banner for coupon management.
7777
case couponManagement = "coupon_management"
7878
}

WooCommerce/Classes/System/WooConstants.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,20 @@ extension WooConstants {
135135
///
136136
case inPersonPaymentsLearnMoreStripe = "https://docs.woocommerce.com/document/stripe/accept-in-person-payments-with-stripe/"
137137

138+
/// URL for the order creation feedback survey (full order creation and simple payments)
139+
///
138140
#if DEBUG
139-
case simplePaymentsPrototypeFeedback = "https://automattic.survey.fm/woo-app-quick-order-testing"
141+
case orderCreationFeedback = "https://automattic.survey.fm/woo-app-order-creation-testing"
140142
#else
141-
case simplePaymentsPrototypeFeedback = "https://automattic.survey.fm/woo-app-quick-order-production"
143+
case orderCreationFeedback = "https://automattic.survey.fm/woo-app-order-creation-production"
142144
#endif
143145

144146
#if DEBUG
145147
case couponManagementFeedback = "https://automattic.survey.fm/woo-app-coupon-management-testing"
146148
#else
147149
case couponManagementFeedback = "https://automattic.survey.fm/woo-app-coupon-management-production"
148150
#endif
151+
149152
/// Returns the URL version of the receiver
150153
///
151154
func asURL() -> URL {

WooCommerce/Classes/ViewRelated/Orders/OrderListViewController.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ private extension OrderListViewController {
245245
self.hideTopBannerView()
246246
case .error:
247247
self.setErrorTopBanner()
248-
case .simplePayments:
249-
self.setSimplePaymentsEnabledTopBanner()
248+
case .orderCreation:
249+
self.setOrderCreationTopBanner()
250250
}
251251
}
252252
.store(in: &cancellables)
@@ -660,15 +660,15 @@ private extension OrderListViewController {
660660
showTopBannerView()
661661
}
662662

663-
/// Sets the `topBannerView` property to a simple payments enabled banner.
663+
/// Sets the `topBannerView` property to an orders banner.
664664
///
665-
func setSimplePaymentsEnabledTopBanner() {
666-
topBannerView = SimplePaymentsTopBannerFactory.createFeatureEnabledBanner(onTopButtonPressed: { [weak self] in
665+
func setOrderCreationTopBanner() {
666+
topBannerView = OrdersTopBannerFactory.createOrdersBanner(onTopButtonPressed: { [weak self] in
667667
self?.tableView.updateHeaderHeight()
668668
}, onDismissButtonPressed: { [weak self] in
669-
self?.viewModel.hideSimplePaymentsBanners = true
669+
self?.viewModel.hideOrdersBanners = true
670670
}, onGiveFeedbackButtonPressed: { [weak self] in
671-
let surveyNavigation = SurveyCoordinatingController(survey: .simplePaymentsPrototype)
671+
let surveyNavigation = SurveyCoordinatingController(survey: .orderCreation)
672672
self?.present(surveyNavigation, animated: true, completion: nil)
673673
})
674674
showTopBannerView()

WooCommerce/Classes/ViewRelated/Orders/OrderListViewModel.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ final class OrderListViewModel {
8585
///
8686
@Published private(set) var topBanner: TopBanner = .none
8787

88-
/// If true, no simple payments banner will be shown as the user has told us that they are not interested in this information.
88+
/// If true, no orders banner will be shown as the user has told us that they are not interested in this information.
8989
/// Resets with every session.
9090
///
91-
@Published var hideSimplePaymentsBanners: Bool = false
91+
@Published var hideOrdersBanners: Bool = false
9292

9393
init(siteID: Int64,
9494
stores: StoresManager = ServiceLocator.stores,
@@ -256,14 +256,14 @@ private extension OrderListViewModel {
256256
}
257257
}
258258

259-
// MARK: Simple Payments
259+
// MARK: - Banners
260260

261261
extension OrderListViewModel {
262262
/// Figures out what top banner should be shown based on the view model internal state.
263263
///
264264
private func bindTopBannerState() {
265265
let errorState = $hasErrorLoadingData.removeDuplicates()
266-
Publishers.CombineLatest(errorState, $hideSimplePaymentsBanners)
266+
Publishers.CombineLatest(errorState, $hideOrdersBanners)
267267
.map { hasError, hasDismissedBanners -> TopBanner in
268268

269269
guard !hasError else {
@@ -274,7 +274,7 @@ extension OrderListViewModel {
274274
return .none
275275
}
276276

277-
return .simplePayments
277+
return .orderCreation
278278
}
279279
.assign(to: &$topBanner)
280280
}
@@ -316,7 +316,7 @@ extension OrderListViewModel {
316316
///
317317
enum TopBanner {
318318
case error
319-
case simplePayments
319+
case orderCreation
320320
case none
321321
}
322322
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import Yosemite
2+
3+
/// Factory for the Orders top banners
4+
///
5+
struct OrdersTopBannerFactory {
6+
7+
/// Creates a banner to be shown on the Orders tab
8+
///
9+
static func createOrdersBanner(onTopButtonPressed: @escaping () -> Void,
10+
onDismissButtonPressed: @escaping () -> Void,
11+
onGiveFeedbackButtonPressed: @escaping () -> Void) -> TopBannerView {
12+
let dismissAction = TopBannerViewModel.ActionButton(title: Localization.dismiss, action: { _ in onDismissButtonPressed() })
13+
let giveFeedbackAction = TopBannerViewModel.ActionButton(title: Localization.giveFeedback, action: { _ in onGiveFeedbackButtonPressed() })
14+
let viewModel = TopBannerViewModel(title: Localization.title,
15+
infoText: Localization.infoText,
16+
icon: .megaphoneIcon,
17+
isExpanded: false,
18+
topButton: .chevron(handler: onTopButtonPressed),
19+
actionButtons: [giveFeedbackAction, dismissAction])
20+
let topBannerView = TopBannerView(viewModel: viewModel)
21+
topBannerView.translatesAutoresizingMaskIntoConstraints = false
22+
return topBannerView
23+
}
24+
}
25+
26+
private extension OrdersTopBannerFactory {
27+
enum Localization {
28+
static let title = NSLocalizedString("Create orders and take payments!", comment: "Title of the banner notice in the Orders tab")
29+
static let infoText = NSLocalizedString("We've been working on making it possible to create orders and take payments from your device! " +
30+
"You can try these features out by tapping on the \"+\" icon",
31+
comment: "Content of the banner notice in the Orders tab")
32+
static let dismiss = NSLocalizedString("Dismiss", comment: "The title of the button to dismiss the Orders top banner")
33+
static let giveFeedback = NSLocalizedString("Give feedback", comment: "Title of the button to give feedback about the Orders features")
34+
}
35+
}

WooCommerce/Classes/ViewRelated/Orders/Simple Payments/SimplePaymentsTopBannerFactory.swift

Lines changed: 0 additions & 35 deletions
This file was deleted.

WooCommerce/Classes/ViewRelated/Survey/SurveyViewController.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ extension SurveyViewController {
6666
case productsVariationsFeedback
6767
case shippingLabelsRelease3Feedback
6868
case addOnsI1
69-
case simplePaymentsPrototype
69+
case orderCreation
7070
case couponManagement
7171

7272
fileprivate var url: URL {
@@ -93,8 +93,8 @@ extension SurveyViewController {
9393
.asURL()
9494
.tagPlatform("ios")
9595
.tagAppVersion(Bundle.main.bundleVersion())
96-
case .simplePaymentsPrototype:
97-
return WooConstants.URLs.simplePaymentsPrototypeFeedback
96+
case .orderCreation:
97+
return WooConstants.URLs.orderCreationFeedback
9898
.asURL()
9999
.tagPlatform("ios")
100100
.tagAppVersion(Bundle.main.bundleVersion())
@@ -110,7 +110,7 @@ extension SurveyViewController {
110110
switch self {
111111
case .inAppFeedback:
112112
return Localization.title
113-
case .productsVariationsFeedback, .shippingLabelsRelease3Feedback, .addOnsI1, .simplePaymentsPrototype, .couponManagement:
113+
case .productsVariationsFeedback, .shippingLabelsRelease3Feedback, .addOnsI1, .orderCreation, .couponManagement:
114114
return Localization.giveFeedback
115115
}
116116
}
@@ -126,8 +126,8 @@ extension SurveyViewController {
126126
return .shippingLabelsRelease3
127127
case .addOnsI1:
128128
return .addOnsI1
129-
case .simplePaymentsPrototype:
130-
return .simplePaymentsPrototype
129+
case .orderCreation:
130+
return .orderCreation
131131
case .couponManagement:
132132
return .couponManagement
133133
}

WooCommerce/WooCommerce.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,6 @@
449449
260C31602524ECA900157BC2 /* IssueRefundViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 260C315F2524ECA900157BC2 /* IssueRefundViewController.swift */; };
450450
260C31622524EEB200157BC2 /* IssueRefundViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 260C31612524EEB200157BC2 /* IssueRefundViewController.xib */; };
451451
260C32BE2527A2DE00157BC2 /* IssueRefundViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 260C32BD2527A2DE00157BC2 /* IssueRefundViewModel.swift */; };
452-
26100B1E2721BAD800473045 /* SimplePaymentsTopBannerFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26100B1D2721BAD800473045 /* SimplePaymentsTopBannerFactory.swift */; };
453452
26100B202722FCAD00473045 /* MockCardPresentPaymentsOnboardingUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26100B1F2722FCAD00473045 /* MockCardPresentPaymentsOnboardingUseCase.swift */; };
454453
2611EE59243A473300A74490 /* ProductCategoryListViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2611EE58243A473300A74490 /* ProductCategoryListViewModelTests.swift */; };
455454
2614EB1C24EB611200968D4B /* TopBannerViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2614EB1B24EB611200968D4B /* TopBannerViewTests.swift */; };
@@ -1231,6 +1230,7 @@
12311230
CC593A6B26EA640800EF0E04 /* PackageCreationError+UI.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC593A6A26EA640800EF0E04 /* PackageCreationError+UI.swift */; };
12321231
CC5C278727EE19A700B25D2A /* NewOrderScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC5C278627EE19A600B25D2A /* NewOrderScreen.swift */; };
12331232
CC5C278B27EE314F00B25D2A /* orders_create.json in Resources */ = {isa = PBXBuildFile; fileRef = CC5C278A27EE314E00B25D2A /* orders_create.json */; };
1233+
CC666F2627F359590045AF1E /* OrdersTopBannerFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC666F2527F359590045AF1E /* OrdersTopBannerFactory.swift */; };
12341234
CC69236226010946002FB669 /* LoginProloguePages.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC69236126010946002FB669 /* LoginProloguePages.swift */; };
12351235
CC6923AC26010D8D002FB669 /* LoginProloguePageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC6923AB26010D8D002FB669 /* LoginProloguePageViewController.swift */; };
12361236
CC72BB6427BD842500837876 /* DisclosureIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC72BB6327BD842500837876 /* DisclosureIndicator.swift */; };
@@ -2143,7 +2143,6 @@
21432143
260C315F2524ECA900157BC2 /* IssueRefundViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IssueRefundViewController.swift; sourceTree = "<group>"; };
21442144
260C31612524EEB200157BC2 /* IssueRefundViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = IssueRefundViewController.xib; sourceTree = "<group>"; };
21452145
260C32BD2527A2DE00157BC2 /* IssueRefundViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IssueRefundViewModel.swift; sourceTree = "<group>"; };
2146-
26100B1D2721BAD800473045 /* SimplePaymentsTopBannerFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimplePaymentsTopBannerFactory.swift; sourceTree = "<group>"; };
21472146
26100B1F2722FCAD00473045 /* MockCardPresentPaymentsOnboardingUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockCardPresentPaymentsOnboardingUseCase.swift; sourceTree = "<group>"; };
21482147
2611EE58243A473300A74490 /* ProductCategoryListViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProductCategoryListViewModelTests.swift; sourceTree = "<group>"; };
21492148
2614EB1B24EB611200968D4B /* TopBannerViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopBannerViewTests.swift; sourceTree = "<group>"; };
@@ -2919,6 +2918,7 @@
29192918
CC593A6A26EA640800EF0E04 /* PackageCreationError+UI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PackageCreationError+UI.swift"; sourceTree = "<group>"; };
29202919
CC5C278627EE19A600B25D2A /* NewOrderScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewOrderScreen.swift; sourceTree = "<group>"; };
29212920
CC5C278A27EE314E00B25D2A /* orders_create.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = orders_create.json; sourceTree = "<group>"; };
2921+
CC666F2527F359590045AF1E /* OrdersTopBannerFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OrdersTopBannerFactory.swift; sourceTree = "<group>"; };
29222922
CC69236126010946002FB669 /* LoginProloguePages.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginProloguePages.swift; sourceTree = "<group>"; };
29232923
CC6923AB26010D8D002FB669 /* LoginProloguePageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginProloguePageViewController.swift; sourceTree = "<group>"; };
29242924
CC72BB6327BD842500837876 /* DisclosureIndicator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisclosureIndicator.swift; sourceTree = "<group>"; };
@@ -4604,7 +4604,6 @@
46044604
2678897A270E6E3C00BD249E /* Simple Payments */ = {
46054605
isa = PBXGroup;
46064606
children = (
4607-
26100B1D2721BAD800473045 /* SimplePaymentsTopBannerFactory.swift */,
46084607
26B9875A273C6A520090E8CA /* Amount */,
46094608
26B9875B273C6A670090E8CA /* Summary */,
46104609
261AA30A27517907009530FE /* Method */,
@@ -6806,6 +6805,7 @@
68066805
57C5FF7D250925000074EC26 /* OrderListViewModel.swift */,
68076806
DE6906E427D7439B00735E3B /* OrdersSplitViewWrapperController.swift */,
68086807
4546E095271F08CD003836F3 /* Order Filters */,
6808+
CC666F2527F359590045AF1E /* OrdersTopBannerFactory.swift */,
68096809
);
68106810
path = Orders;
68116811
sourceTree = "<group>";
@@ -8741,6 +8741,7 @@
87418741
457509E4267B9E91005FA2EA /* AggregatedProductListViewController.swift in Sources */,
87428742
D8815B0D263861A400EDAD62 /* CardPresentModalSuccess.swift in Sources */,
87438743
0235595524496B6D004BE2B8 /* BottomSheetListSelectorCommand.swift in Sources */,
8744+
CC666F2627F359590045AF1E /* OrdersTopBannerFactory.swift in Sources */,
87448745
747AA0892107CEC60047A89B /* AnalyticsProvider.swift in Sources */,
87458746
D89CFF3A25B43BBB000E4683 /* WrongAccountErrorViewModel.swift in Sources */,
87468747
02B2829227C4808D004A332A /* InfiniteScrollIndicator.swift in Sources */,
@@ -8840,7 +8841,6 @@
88408841
023D877925EC8BCB00625963 /* UIScrollView+LargeTitleWorkaround.swift in Sources */,
88418842
2664210326F40FB1001FC5B4 /* View+ScrollModifiers.swift in Sources */,
88428843
02695770237281A9001BA0BF /* AztecTextViewAttachmentHandler.swift in Sources */,
8843-
26100B1E2721BAD800473045 /* SimplePaymentsTopBannerFactory.swift in Sources */,
88448844
AEA3F90F27BE8EB400B9F555 /* ShippingLineDetailsViewModel.swift in Sources */,
88458845
26771A14256FFA8700EE030E /* IssueRefundCoordinatingController.swift in Sources */,
88468846
027A2E162513356100DA6ACB /* AppleIDCredentialChecker.swift in Sources */,

WooCommerce/WooCommerceTests/ViewRelated/Orders/OrderListViewModelTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ final class OrderListViewModelTests: XCTestCase {
231231
XCTAssertFalse(resynchronizeRequested)
232232
}
233233

234-
func test_when_having_no_error_shows_simple_payments_banner() {
234+
func test_when_having_no_error_shows_orders_banner() {
235235
// Given
236236
let viewModel = OrderListViewModel(siteID: siteID, filters: nil)
237237

@@ -240,7 +240,7 @@ final class OrderListViewModelTests: XCTestCase {
240240

241241
// Then
242242
waitUntil {
243-
viewModel.topBanner == .simplePayments
243+
viewModel.topBanner == .orderCreation
244244
}
245245
}
246246

@@ -258,29 +258,29 @@ final class OrderListViewModelTests: XCTestCase {
258258
}
259259
}
260260

261-
func test_dismissing_simple_payments_banners_does_not_show_banners() {
261+
func test_dismissing_orders_banners_does_not_show_banners() {
262262
// Given
263263
let stores = MockStoresManager(sessionManager: .testingInstance)
264264
let viewModel = OrderListViewModel(siteID: siteID, stores: stores, filters: nil)
265265

266266
// When
267267
viewModel.activate()
268-
viewModel.hideSimplePaymentsBanners = true
268+
viewModel.hideOrdersBanners = true
269269

270270
// Then
271271
waitUntil {
272272
viewModel.topBanner == .none
273273
}
274274
}
275275

276-
func test_hiding_simplePayments_banners_still_shows_error_banner() {
276+
func test_hiding_orders_banners_still_shows_error_banner() {
277277
// Given
278278
let viewModel = OrderListViewModel(siteID: siteID, filters: nil)
279279

280280
// When
281281
viewModel.activate()
282282
viewModel.hasErrorLoadingData = true
283-
viewModel.hideSimplePaymentsBanners = true
283+
viewModel.hideOrdersBanners = true
284284

285285
// Then
286286
waitUntil {

0 commit comments

Comments
 (0)