Skip to content

Commit

Permalink
Fix single product page view tracks. (#9644)
Browse files Browse the repository at this point in the history
  • Loading branch information
brettshumaker authored Oct 30, 2024
1 parent a186e7f commit e1adde6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions changelog/9550-fix-single-product-page-view-tracks
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fixed single product page view tracks when BNPL and PRB payment methods are inactive.
12 changes: 11 additions & 1 deletion includes/class-woopay-tracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -622,12 +622,22 @@ public function add_frontend_tracks_scripts() {

WC_Payments::register_script_with_dependencies( 'wcpay-frontend-tracks', 'dist/frontend-tracks' );

wp_enqueue_script( 'wcpay-frontend-tracks' );
// Define wcpayConfig before the frontend tracks script if it hasn't been defined yet.
$wcpay_config = rawurlencode( wp_json_encode( WC_Payments::get_wc_payments_checkout()->get_payment_fields_js_config() ) );
wp_add_inline_script(
'wcpay-frontend-tracks',
"
var wcpayConfig = wcpayConfig || JSON.parse( decodeURIComponent( '" . esc_js( $wcpay_config ) . "' ) );
",
'before'
);

wp_localize_script(
'wcpay-frontend-tracks',
'wcPayFrontendTracks',
$frontent_tracks
);

wp_enqueue_script( 'wcpay-frontend-tracks' );
}
}

0 comments on commit e1adde6

Please sign in to comment.