Skip to content

Commit

Permalink
Add a Track event to the Pay For Order page (#7538)
Browse files Browse the repository at this point in the history
  • Loading branch information
malithsen authored Oct 26, 2023
1 parent a2c7b66 commit 641fb60
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 4 additions & 0 deletions changelog/add-pay-for-order-tracks
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: dev

Add pay-for-order Tracks events
8 changes: 4 additions & 4 deletions includes/class-wc-payments-woopay-button-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '';
}

Expand Down
10 changes: 10 additions & 0 deletions includes/class-woopay-tracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ] );
}

/**
Expand Down Expand Up @@ -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.
*/
Expand Down

0 comments on commit 641fb60

Please sign in to comment.