File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
ViewRelated/Orders/Order Creation Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -354,7 +354,7 @@ extension WooAnalyticsEvent {
354354 WooAnalyticsEvent ( statName: . orderProductAdd, properties: [ Keys . flow: flow. rawValue] )
355355 }
356356
357- static func orderCustomerDetailsAdd ( flow: Flow , hasDifferentShippingDetails: Bool ) -> WooAnalyticsEvent {
357+ static func orderCustomerAdd ( flow: Flow , hasDifferentShippingDetails: Bool ) -> WooAnalyticsEvent {
358358 WooAnalyticsEvent ( statName: . orderCustomerAdd, properties: [
359359 Keys . flow: flow. rawValue,
360360 Keys . hasDifferentShippingDetails: hasDifferentShippingDetails
Original file line number Diff line number Diff line change @@ -201,6 +201,7 @@ final class NewOrderViewModel: ObservableObject {
201201 onAddressUpdate: { [ weak self] updatedAddressData in
202202 self ? . orderDetails. billingAddress = updatedAddressData. billingAddress
203203 self ? . orderDetails. shippingAddress = updatedAddressData. shippingAddress
204+ self ? . trackCustomerDetailsAdded ( )
204205 } )
205206 }
206207
@@ -481,6 +482,18 @@ private extension NewOrderViewModel {
481482 }
482483 . assign ( to: & $paymentDataViewModel)
483484 }
485+
486+ /// Tracks when customer details have been added
487+ ///
488+ func trackCustomerDetailsAdded( ) {
489+ let areAddressesDifferent : Bool = {
490+ guard let billingAddress = orderDetails. billingAddress, let shippingAddress = orderDetails. shippingAddress else {
491+ return false
492+ }
493+ return billingAddress != shippingAddress
494+ } ( )
495+ analytics. track ( event: WooAnalyticsEvent . Orders. orderCustomerAdd ( flow: . creation, hasDifferentShippingDetails: areAddressesDifferent) )
496+ }
484497}
485498
486499private extension NewOrderViewModel {
You can’t perform that action at this time.
0 commit comments