Skip to content

Commit

Permalink
PRESS12-44 Added a GA event for WooPay connection.
Browse files Browse the repository at this point in the history
  • Loading branch information
mamatharao05 committed Nov 26, 2024
1 parent 7c1abaa commit ff08d0e
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions includes/Listeners/Commerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function register_hooks() {
add_filter( 'update_option_ewc4wp_sso_account_status', array( $this, 'ecomdash_connected' ), 10, 2 );
add_filter( 'woocommerce_update_product', array( $this, 'product_created_or_updated' ), 100, 2 );
add_action( 'update_option_woocommerce_custom_orders_table_enabled', array( $this, 'woocommerce_hpos_enabled' ), 10, 3 );
add_filter( 'pre_update_option_wcpay_account_connect_wpcom_connection_success', array( $this, 'woopay_connection' ), 10, 2 );
}

/**
Expand Down Expand Up @@ -329,4 +330,30 @@ public function woocommerce_hpos_enabled( $old_value, $new_value, string $option
);
}
}

/**
* WooPay connected
*
* @param string $new_option New value of the woopay connection option
* @param string $old_option Old value of the woopay connection option
*
* @return string The new option value
*/
public function woopay_connection( $new_option, $old_option ) {
$url = is_ssl() ? 'https://' : 'http://';
$url .= $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$data = array(
'label_key' => 'provider',
'provider' => 'woopay',
'page' => $url,
);
if ( $new_option !== $old_option && ! empty( $new_option ) ) {
$this->push(
'payment_connected',
$data
);
}

return $new_option;
}
}

0 comments on commit ff08d0e

Please sign in to comment.