Skip to content

Commit

Permalink
Record a Tracks event when viewing the order success page (#7859)
Browse files Browse the repository at this point in the history
  • Loading branch information
malithsen authored Dec 12, 2023
1 parent a30b28c commit ef7a13c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions changelog/add-thank-you-page-tracks
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: dev

Thank you page Tracks event
17 changes: 17 additions & 0 deletions includes/class-woopay-tracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public function __construct( $http ) {
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' ] );
add_action( 'woocommerce_thankyou', [ $this, 'thank_you_page_view' ] );
}

/**
Expand Down Expand Up @@ -460,6 +461,22 @@ public function must_save_payment_method_to_platform() {
);
}

/**
* Record a Tracks event that Thank you page was viewed for a WCPay order.
*
* @param int $order_id The ID of the order.
* @return void
*/
public function thank_you_page_view($order_id) {
$order = wc_get_order( $order_id );

if ( ! $order || 'woocommerce_payments' !== $order->get_payment_method() ) {
return;
}

$this->maybe_record_wcpay_shopper_event( 'order_success_page_view' );
}

/**
* Record a Tracks event that the WooPay express button locations has been updated.
*
Expand Down

0 comments on commit ef7a13c

Please sign in to comment.