Skip to content

Commit

Permalink
PLANET-7640 Added code to ensure Stripe event is added on when needed (
Browse files Browse the repository at this point in the history
…#2437)

- Add check to ensure form being submitted has a stripe feed
- Check is used to trigger stripe dataLayer event
  • Loading branch information
Osong-Michael authored Nov 15, 2024
1 parent ccb3b52 commit bb16964
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/GravityFormsExtensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,11 @@ public function p4_gf_custom_confirmation_redirect($confirmation, $form, $entry)
// Get the tag manager data layer ID from master theme settings
$options = get_option('planet4_options');
$gtm_id = $options['google_tag_manager_identifier'];
$purchase_event = $this->p4_gf_stripe_custom_success_event($entry, $form);
$is_stripe_feed = false;
if (function_exists('gf_stripe')) {
$is_stripe_feed = gf_stripe()->has_feed($form['id']);
}
$purchase_event = $is_stripe_feed ? $this->p4_gf_stripe_custom_success_event($entry, $form) : [];

$email_hash = $this->p4_gf_get_email_hash($form, $entry);

Expand Down Expand Up @@ -869,11 +873,13 @@ public function p4_gf_custom_confirmation_redirect($confirmation, $form, $entry)
window.dataLayer.push(push_data);
// One time payment returns Paid status, recurring payments returns Active status
if (
if ("' . $is_stripe_feed . '" == true) {
if (
"' . $this->is_payment_successful . '" == "Paid" ||
"' . $this->is_payment_successful . '" == "Active"
) {
window.dataLayer.push(purchase_event);
"' . $this->is_payment_successful . '" == "Active"
) {
window.dataLayer.push(purchase_event);
}
}
const gp_user_id_event = new CustomEvent("gp_user_id_set", {"detail":
{"gp_user_id": "' . $email_hash . '" }});
Expand Down

0 comments on commit bb16964

Please sign in to comment.