Skip to content

Commit

Permalink
Added a debug log for debugging the 'purchase' event
Browse files Browse the repository at this point in the history
  • Loading branch information
TorbenLundsgaard committed Mar 12, 2024
1 parent cadfe85 commit 98b3e6f
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion assets/admin/settings.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '53fcd2206b7b02fb47f5');
<?php return array('dependencies' => array('lodash', 'react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '918cd00c99181c5052ca');
2 changes: 1 addition & 1 deletion assets/admin/settings.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ Release date: 2024-MM-DD
Find out about what's new in our [our release post](https://gtmkit.com/gtm-kit-1-20/).

#### Enhancements:
* Added a debug log for debugging the 'purchase' event without make a purchase.

#### Bugfixes:

Expand Down
5 changes: 5 additions & 0 deletions src/Integration/EasyDigitalDownloads.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,11 @@ public function get_datalayer_content_order_received( array $data_layer ): array

edd_add_order_meta( $order_id, 'gtmkit_order_tracked', 1 );

if ( $this->options->get( 'general', 'debug_log' ) ) {
error_log( 'GTM Kit: purchase event datalayer' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions
error_log( print_r( $data_layer, 1 ) ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions
}

return apply_filters( 'gtmkit_datalayer_content_order_received', $data_layer );
}

Expand Down
5 changes: 5 additions & 0 deletions src/Integration/WooCommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,11 @@ public function get_purchase_event( WC_Order $order, array $data_layer = [] ): a

$data_layer['ecommerce']['items'] = $this->get_order_items( $order );

if ( $this->options->get( 'general', 'debug_log' ) ) {
$logger = wc_get_logger();
$logger->info( wc_print_r( $data_layer, true ), array( 'source' => 'gtmkit-purchase' ) );
}

return $data_layer;
}

Expand Down
5 changes: 5 additions & 0 deletions src/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ final class Options {
'constant' => 'GTMKIT_CONSOLE_LOG',
'type' => 'boolean',
],
'debug_log' => [
'default' => false,
'constant' => 'GTMKIT_DEBUG_LOG',
'type' => 'boolean',
],
'gtm_auth' => [
'default' => '',
'constant' => 'GTMKIT_AUTH',
Expand Down

0 comments on commit 98b3e6f

Please sign in to comment.