From a9ac773178987c96f08a3e07b584e85fa6b11649 Mon Sep 17 00:00:00 2001 From: Malith Senaweera Date: Fri, 20 Oct 2023 15:21:32 -0500 Subject: [PATCH 1/2] Add a Track event to the Pay For Order page --- includes/class-wc-payments-woopay-button-handler.php | 8 ++++---- includes/class-woopay-tracker.php | 10 ++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/includes/class-wc-payments-woopay-button-handler.php b/includes/class-wc-payments-woopay-button-handler.php index ab637e1040c..37529dc030e 100644 --- a/includes/class-wc-payments-woopay-button-handler.php +++ b/includes/class-wc-payments-woopay-button-handler.php @@ -454,14 +454,14 @@ public function get_button_context() { return 'cart'; } - if ( $this->is_checkout() ) { - return 'checkout'; - } - if ( $this->is_pay_for_order_page() ) { return 'pay_for_order'; } + if ( $this->is_checkout() ) { + return 'checkout'; + } + return ''; } diff --git a/includes/class-woopay-tracker.php b/includes/class-woopay-tracker.php index 2006fb19906..564fd0c5033 100644 --- a/includes/class-woopay-tracker.php +++ b/includes/class-woopay-tracker.php @@ -70,6 +70,7 @@ public function __construct( $http ) { add_action( 'woocommerce_checkout_order_processed', [ $this, 'checkout_order_processed' ] ); add_action( 'woocommerce_blocks_checkout_order_processed', [ $this, 'checkout_order_processed' ] ); add_action( 'woocommerce_payments_save_user_in_woopay', [ $this, 'must_save_payment_method_to_platform' ] ); + add_action( 'before_woocommerce_pay_form', [ $this, 'pay_for_order_page_view' ] ); } /** @@ -423,6 +424,15 @@ public function classic_product_page_view() { ); } + /** + * Record a Tracks event that the pay-for-order page has loaded. + */ + public function pay_for_order_page_view() { + $this->maybe_record_wcpay_shopper_event( + 'pay_for_order_page_view' + ); + } + /** * Record a Tracks event that the order has been processed. */ From 7df5ff6941e9d4f0fe6b40d995de0bbe18c57c13 Mon Sep 17 00:00:00 2001 From: Malith Senaweera Date: Mon, 23 Oct 2023 12:45:51 -0500 Subject: [PATCH 2/2] Add changelog entry --- changelog/add-pay-for-order-tracks | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 changelog/add-pay-for-order-tracks diff --git a/changelog/add-pay-for-order-tracks b/changelog/add-pay-for-order-tracks new file mode 100644 index 00000000000..a1e84990229 --- /dev/null +++ b/changelog/add-pay-for-order-tracks @@ -0,0 +1,4 @@ +Significance: minor +Type: dev + +Add pay-for-order Tracks events