From c3c10327784862f12bfad648fbaf3d7b7c01b113 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Fri, 16 Mar 2012 10:40:09 +0000 Subject: [PATCH] e-commerce tracking - SKU and Category. prepend sku --- readme.txt | 1 + woocommerce-functions.php | 26 +++++++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/readme.txt b/readme.txt index e0c91616966..cd3e13ac56f 100644 --- a/readme.txt +++ b/readme.txt @@ -144,6 +144,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc == Changelog == = 1.5.3 = +* Tweak - e-commerce tracking - SKU and Category (thanks jdiderik) * Localization - Made the monthly sales dashboard widget translatable (by GeertDD) * Localization - Updated Danish Translation (by FrederikRS) diff --git a/woocommerce-functions.php b/woocommerce-functions.php index 7e8075cfa8c..a586952540c 100644 --- a/woocommerce-functions.php +++ b/woocommerce-functions.php @@ -1129,19 +1129,23 @@ function woocommerce_ecommerce_tracking( $order_id ) { get_items()) foreach($order->get_items() as $item) : $_product = $order->get_product_from_item( $item ); ?> _gaq.push(['_addItem', '', // order ID - required - 'sku) && !empty($_product->sku)){ echo $_product->sku; } else { echo $_product->id; }; ?>', // SKU/code - required + 'sku)) + echo __('SKU:', 'woocommerce') . ' ' . $_product->sku; + else + echo $_product->id; + ?>', // SKU/code - required '', // product name 'variation_data)){ - echo woocommerce_get_formatted_variation( $_product->variation_data, true ); - } else { - $out = array(); - $categories = get_the_terms($_product->id, 'product_cat'); - foreach ( $categories as $category ){ - $out[] = $category->name; - } - echo join( "/", $out); - } - ?>', // category or variation + echo woocommerce_get_formatted_variation( $_product->variation_data, true ); + } else { + $out = array(); + $categories = get_the_terms($_product->id, 'product_cat'); + foreach ( $categories as $category ){ + $out[] = $category->name; + } + echo join( "/", $out); + } + ?>', // category or variation '', // unit price - required '' // quantity - required ]);