Version Description
- 2022-08-03 =
- Fix - Custom Order table compatibility.
Download this release
Release Info
| Developer | nimakarimi |
| Plugin | |
| Version | 1.5.13 |
| Comparing to | |
| See all releases | |
Code changes from version 1.5.12 to 1.5.13
changelog.txt
CHANGED
|
@@ -1,5 +1,8 @@
|
|
| 1 |
*** Changelog ***
|
| 2 |
|
|
|
|
|
|
|
|
|
|
| 3 |
= 1.5.12 - 2022-07-27 =
|
| 4 |
* Tweak - WC 6.8 compatibility.
|
| 5 |
|
| 1 |
*** Changelog ***
|
| 2 |
|
| 3 |
+
= 1.5.13 - 2022-08-03 =
|
| 4 |
+
* Fix - Custom Order table compatibility.
|
| 5 |
+
|
| 6 |
= 1.5.12 - 2022-07-27 =
|
| 7 |
* Tweak - WC 6.8 compatibility.
|
| 8 |
|
includes/class-wc-abstract-google-analytics-js.php
CHANGED
|
@@ -160,16 +160,16 @@ abstract class WC_Abstract_Google_Analytics_JS {
|
|
| 160 |
* Returns a 'category' JSON line based on $product
|
| 161 |
*
|
| 162 |
* @param WC_Product $_product Product to pull info for
|
| 163 |
-
* @return string
|
| 164 |
*/
|
| 165 |
protected static function product_get_category_line( $_product ) {
|
| 166 |
-
$out =
|
| 167 |
-
$variation_data =
|
| 168 |
$categories = get_the_terms( $_product->get_id(), 'product_cat' );
|
| 169 |
|
| 170 |
if ( is_array( $variation_data ) && ! empty( $variation_data ) ) {
|
| 171 |
-
$parent_product = wc_get_product(
|
| 172 |
-
$categories
|
| 173 |
}
|
| 174 |
|
| 175 |
if ( $categories ) {
|
|
@@ -178,18 +178,18 @@ abstract class WC_Abstract_Google_Analytics_JS {
|
|
| 178 |
}
|
| 179 |
}
|
| 180 |
|
| 181 |
-
return "'" . esc_js( join(
|
| 182 |
}
|
| 183 |
|
| 184 |
/**
|
| 185 |
* Returns a 'variant' JSON line based on $product
|
| 186 |
*
|
| 187 |
* @param WC_Product $_product Product to pull info for
|
| 188 |
-
* @return string
|
| 189 |
*/
|
| 190 |
protected static function product_get_variant_line( $_product ) {
|
| 191 |
$out = '';
|
| 192 |
-
$variation_data =
|
| 193 |
|
| 194 |
if ( is_array( $variation_data ) && ! empty( $variation_data ) ) {
|
| 195 |
$out = "'" . esc_js( wc_get_formatted_variation( $variation_data, true ) ) . "',";
|
| 160 |
* Returns a 'category' JSON line based on $product
|
| 161 |
*
|
| 162 |
* @param WC_Product $_product Product to pull info for
|
| 163 |
+
* @return string Line of JSON
|
| 164 |
*/
|
| 165 |
protected static function product_get_category_line( $_product ) {
|
| 166 |
+
$out = [];
|
| 167 |
+
$variation_data = $_product->is_type( 'variation' ) ? wc_get_product_variation_attributes( $_product->get_id() ) : false;
|
| 168 |
$categories = get_the_terms( $_product->get_id(), 'product_cat' );
|
| 169 |
|
| 170 |
if ( is_array( $variation_data ) && ! empty( $variation_data ) ) {
|
| 171 |
+
$parent_product = wc_get_product( $_product->get_parent_id() );
|
| 172 |
+
$categories = get_the_terms( $parent_product->get_id(), 'product_cat' );
|
| 173 |
}
|
| 174 |
|
| 175 |
if ( $categories ) {
|
| 178 |
}
|
| 179 |
}
|
| 180 |
|
| 181 |
+
return "'" . esc_js( join( '/', $out ) ) . "',";
|
| 182 |
}
|
| 183 |
|
| 184 |
/**
|
| 185 |
* Returns a 'variant' JSON line based on $product
|
| 186 |
*
|
| 187 |
* @param WC_Product $_product Product to pull info for
|
| 188 |
+
* @return string Line of JSON
|
| 189 |
*/
|
| 190 |
protected static function product_get_variant_line( $_product ) {
|
| 191 |
$out = '';
|
| 192 |
+
$variation_data = $_product->is_type( 'variation' ) ? wc_get_product_variation_attributes( $_product->get_id() ) : false;
|
| 193 |
|
| 194 |
if ( is_array( $variation_data ) && ! empty( $variation_data ) ) {
|
| 195 |
$out = "'" . esc_js( wc_get_formatted_variation( $variation_data, true ) ) . "',";
|
includes/class-wc-google-analytics.php
CHANGED
|
@@ -381,7 +381,8 @@ class WC_Google_Analytics extends WC_Integration {
|
|
| 381 |
// Check if is order received page and stop when the products and not tracked
|
| 382 |
if ( is_order_received_page() && 'yes' === $this->ga_ecommerce_tracking_enabled ) {
|
| 383 |
$order_id = isset( $wp->query_vars['order-received'] ) ? $wp->query_vars['order-received'] : 0;
|
| 384 |
-
|
|
|
|
| 385 |
$display_ecommerce_tracking = true;
|
| 386 |
echo $this->get_ecommerce_tracking_code( $order_id );
|
| 387 |
}
|
|
@@ -433,7 +434,8 @@ class WC_Google_Analytics extends WC_Integration {
|
|
| 433 |
$code = $this->get_tracking_instance()->add_transaction( $order );
|
| 434 |
|
| 435 |
// Mark the order as tracked.
|
| 436 |
-
|
|
|
|
| 437 |
|
| 438 |
return '
|
| 439 |
<!-- WooCommerce Google Analytics Integration -->
|
| 381 |
// Check if is order received page and stop when the products and not tracked
|
| 382 |
if ( is_order_received_page() && 'yes' === $this->ga_ecommerce_tracking_enabled ) {
|
| 383 |
$order_id = isset( $wp->query_vars['order-received'] ) ? $wp->query_vars['order-received'] : 0;
|
| 384 |
+
$order = wc_get_order( $order_id );
|
| 385 |
+
if ( $order && ! (bool) $order->get_meta( '_ga_tracked' ) ) {
|
| 386 |
$display_ecommerce_tracking = true;
|
| 387 |
echo $this->get_ecommerce_tracking_code( $order_id );
|
| 388 |
}
|
| 434 |
$code = $this->get_tracking_instance()->add_transaction( $order );
|
| 435 |
|
| 436 |
// Mark the order as tracked.
|
| 437 |
+
$order->update_meta_data( '_ga_tracked', 1 );
|
| 438 |
+
$order->save();
|
| 439 |
|
| 440 |
return '
|
| 441 |
<!-- WooCommerce Google Analytics Integration -->
|
includes/class-wc-google-gtag-js.php
CHANGED
|
@@ -164,14 +164,14 @@ class WC_Google_Gtag_JS extends WC_Abstract_Google_Analytics_JS {
|
|
| 164 |
}
|
| 165 |
$items .= "]";
|
| 166 |
|
| 167 |
-
$code
|
| 168 |
'transaction_id': '" . esc_js( $order->get_order_number() ) . "',
|
| 169 |
'affiliation': '" . esc_js( get_bloginfo( 'name' ) ) . "',
|
| 170 |
'value': '" . esc_js( $order->get_total() ) . "',
|
| 171 |
'tax': '" . esc_js( $order->get_total_tax() ) . "',
|
| 172 |
'shipping': '" . esc_js( $order->get_total_shipping() ) . "',
|
| 173 |
-
'currency': '" . esc_js(
|
| 174 |
-
'items':
|
| 175 |
} );";
|
| 176 |
|
| 177 |
return $code;
|
|
@@ -180,14 +180,14 @@ class WC_Google_Gtag_JS extends WC_Abstract_Google_Analytics_JS {
|
|
| 180 |
/**
|
| 181 |
* Add Item
|
| 182 |
*
|
| 183 |
-
* @param WC_Order
|
| 184 |
-
* @param WC_Order_Item $item
|
| 185 |
*/
|
| 186 |
protected function add_item( $order, $item ) {
|
| 187 |
-
$_product =
|
| 188 |
$variant = self::product_get_variant_line( $_product );
|
| 189 |
|
| 190 |
-
$code
|
| 191 |
$code .= "'id': '" . esc_js( $_product->get_sku() ? $_product->get_sku() : $_product->get_id() ) . "',";
|
| 192 |
$code .= "'name': '" . esc_js( $item['name'] ) . "',";
|
| 193 |
$code .= "'category': " . self::product_get_category_line( $_product );
|
|
@@ -198,7 +198,7 @@ class WC_Google_Gtag_JS extends WC_Abstract_Google_Analytics_JS {
|
|
| 198 |
|
| 199 |
$code .= "'price': '" . esc_js( $order->get_item_total( $item ) ) . "',";
|
| 200 |
$code .= "'quantity': '" . esc_js( $item['qty'] ) . "'";
|
| 201 |
-
$code .=
|
| 202 |
|
| 203 |
return $code;
|
| 204 |
}
|
| 164 |
}
|
| 165 |
$items .= "]";
|
| 166 |
|
| 167 |
+
$code = self::tracker_var() . "( 'event', 'purchase', {
|
| 168 |
'transaction_id': '" . esc_js( $order->get_order_number() ) . "',
|
| 169 |
'affiliation': '" . esc_js( get_bloginfo( 'name' ) ) . "',
|
| 170 |
'value': '" . esc_js( $order->get_total() ) . "',
|
| 171 |
'tax': '" . esc_js( $order->get_total_tax() ) . "',
|
| 172 |
'shipping': '" . esc_js( $order->get_total_shipping() ) . "',
|
| 173 |
+
'currency': '" . esc_js( $order->get_currency() ) . "',
|
| 174 |
+
'items': {$items},
|
| 175 |
} );";
|
| 176 |
|
| 177 |
return $code;
|
| 180 |
/**
|
| 181 |
* Add Item
|
| 182 |
*
|
| 183 |
+
* @param WC_Order $order WC_Order Object
|
| 184 |
+
* @param WC_Order_Item $item The item to add to a transaction/order
|
| 185 |
*/
|
| 186 |
protected function add_item( $order, $item ) {
|
| 187 |
+
$_product = $item->get_product();
|
| 188 |
$variant = self::product_get_variant_line( $_product );
|
| 189 |
|
| 190 |
+
$code = '{';
|
| 191 |
$code .= "'id': '" . esc_js( $_product->get_sku() ? $_product->get_sku() : $_product->get_id() ) . "',";
|
| 192 |
$code .= "'name': '" . esc_js( $item['name'] ) . "',";
|
| 193 |
$code .= "'category': " . self::product_get_category_line( $_product );
|
| 198 |
|
| 199 |
$code .= "'price': '" . esc_js( $order->get_item_total( $item ) ) . "',";
|
| 200 |
$code .= "'quantity': '" . esc_js( $item['qty'] ) . "'";
|
| 201 |
+
$code .= '},';
|
| 202 |
|
| 203 |
return $code;
|
| 204 |
}
|
readme.txt
CHANGED
|
@@ -3,7 +3,7 @@ Contributors: woocommerce, automattic, claudiosanches, bor0, royho, laurendaviss
|
|
| 3 |
Tags: woocommerce, google analytics
|
| 4 |
Requires at least: 3.9
|
| 5 |
Tested up to: 5.9
|
| 6 |
-
Stable tag: 1.5.
|
| 7 |
License: GPLv3
|
| 8 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
| 9 |
|
|
@@ -60,6 +60,9 @@ Exact wording depends on the national data privacy laws and should be adjusted.
|
|
| 60 |
|
| 61 |
== Changelog ==
|
| 62 |
|
|
|
|
|
|
|
|
|
|
| 63 |
= 1.5.12 - 2022-07-27 =
|
| 64 |
* Tweak - WC 6.8 compatibility.
|
| 65 |
|
| 3 |
Tags: woocommerce, google analytics
|
| 4 |
Requires at least: 3.9
|
| 5 |
Tested up to: 5.9
|
| 6 |
+
Stable tag: 1.5.13
|
| 7 |
License: GPLv3
|
| 8 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
| 9 |
|
| 60 |
|
| 61 |
== Changelog ==
|
| 62 |
|
| 63 |
+
= 1.5.13 - 2022-08-03 =
|
| 64 |
+
* Fix - Custom Order table compatibility.
|
| 65 |
+
|
| 66 |
= 1.5.12 - 2022-07-27 =
|
| 67 |
* Tweak - WC 6.8 compatibility.
|
| 68 |
|
woocommerce-google-analytics-integration.php
CHANGED
|
@@ -5,7 +5,7 @@
|
|
| 5 |
* Description: Allows Google Analytics tracking code to be inserted into WooCommerce store pages.
|
| 6 |
* Author: WooCommerce
|
| 7 |
* Author URI: https://woocommerce.com
|
| 8 |
-
* Version: 1.5.
|
| 9 |
* WC requires at least: 3.2
|
| 10 |
* WC tested up to: 6.8
|
| 11 |
* Tested up to: 6.0
|
|
@@ -20,7 +20,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
| 20 |
|
| 21 |
if ( ! class_exists( 'WC_Google_Analytics_Integration' ) ) {
|
| 22 |
|
| 23 |
-
define( 'WC_GOOGLE_ANALYTICS_INTEGRATION_VERSION', '1.5.
|
| 24 |
|
| 25 |
// Maybe show the GA Pro notice on plugin activation.
|
| 26 |
register_activation_hook(
|
| 5 |
* Description: Allows Google Analytics tracking code to be inserted into WooCommerce store pages.
|
| 6 |
* Author: WooCommerce
|
| 7 |
* Author URI: https://woocommerce.com
|
| 8 |
+
* Version: 1.5.13
|
| 9 |
* WC requires at least: 3.2
|
| 10 |
* WC tested up to: 6.8
|
| 11 |
* Tested up to: 6.0
|
| 20 |
|
| 21 |
if ( ! class_exists( 'WC_Google_Analytics_Integration' ) ) {
|
| 22 |
|
| 23 |
+
define( 'WC_GOOGLE_ANALYTICS_INTEGRATION_VERSION', '1.5.13' ); // WRCS: DEFINED_VERSION.
|
| 24 |
|
| 25 |
// Maybe show the GA Pro notice on plugin activation.
|
| 26 |
register_activation_hook(
|
