e-commerce tracking - SKU and Category. prepend sku

This commit is contained in:
Mike Jolley 2012-03-16 10:40:09 +00:00
parent 26c0e15f36
commit c3c1032778
2 changed files with 16 additions and 11 deletions

View File

@ -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)

View File

@ -1129,19 +1129,23 @@ function woocommerce_ecommerce_tracking( $order_id ) {
<?php if ($order->get_items()) foreach($order->get_items() as $item) : $_product = $order->get_product_from_item( $item ); ?>
_gaq.push(['_addItem',
'<?php echo $order_id; ?>', // order ID - required
'<?php if (isset($_product->sku) && !empty($_product->sku)){ echo $_product->sku; } else { echo $_product->id; }; ?>', // SKU/code - required
'<?php if (!empty($_product->sku))
echo __('SKU:', 'woocommerce') . ' ' . $_product->sku;
else
echo $_product->id;
?>', // SKU/code - required
'<?php echo $item['name']; ?>', // product name
'<?php if (isset($_product->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
'<?php echo ($item['line_total']/$item['qty']); ?>', // unit price - required
'<?php echo $item['qty']; ?>' // quantity - required
]);