Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PRESS12-44 Added a GA event for WooPay connection. #114

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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( 'update_option_wcpay_account_data', 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 ( empty( $old_option ) && ! empty( $new_option ) ) {
$this->push(
'payment_connected',
$data
);
}

return $new_option;
}
}
Loading