Skip to content

Commit

Permalink
more debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
diosmosis committed Jan 21, 2025
1 parent da8f368 commit 3b19ef9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions classes/WpMatomo/Ecommerce/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ protected function make_matomo_js_tracker_call( $params ) {
}

protected function wrap_script( $script ) {
$this->logger->log('tracking script: ' . $script);
$this->logger->log('should track in background: ' . $this->should_track_background());
$this->logger->log('const: ' . (defined('MATOMO_TRACK_ECOMMERCE_SERVER_SIDE') ? MATOMO_TRACK_ECOMMERCE_SERVER_SIDE : 'undefined'));
if ( $this->should_track_background() ) {
foreach ( $this->ajax_tracker_calls as $call ) {
$methods = [
Expand Down
5 changes: 5 additions & 0 deletions classes/WpMatomo/Ecommerce/Woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public function register_hooks() {
add_action( 'woocommerce_cart_item_set_quantity', [ $this, 'on_cart_updated_safe' ], 99999, 0 );
add_action( 'woocommerce_thankyou', [ $this, 'anonymise_orderid_in_url' ], 1, 1 );
add_action( 'woocommerce_order_status_changed', [ $this, 'on_order_status_change' ], 10, 3 );
add_action( 'woocommerce_after_calculate_totals', function ($cart) {
$this->logger->log( 'after calculate 1: ' . wp_json_encode( $cart->get_cart() ) );
$this->logger->log( 'after calculate 2: ' . wp_json_encode( $cart->get_totals() ) );
} );

if ( ! $this->should_track_background() ) {
// prevent possibly executing same event twice where eg first a PHP Matomo tracker request is created
Expand Down Expand Up @@ -146,6 +150,7 @@ public function on_cart_updated( $val = null, $is_coupon_update = false ) {

if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
$this->logger->log( 'cart updated to: ' . wp_json_encode( $cart_content ) );
$this->logger->log( 'cart totals: ' . wp_json_encode( $cart->get_totals() ) );
}

$tracking_code = '';
Expand Down

0 comments on commit 3b19ef9

Please sign in to comment.