function shopp_transaction_tracking($push) { global $Shopp; // Only process if we're in the checkout process (receipt page) if (version_compare(substr(SHOPP_VERSION, 0, 3), '1.1') >= 0) { // Only process if we're in the checkout process (receipt page) if (function_exists('is_shopp_page') && !is_shopp_page('checkout')) { return $push; } if (empty($Shopp->Order->purchase)) { return $push; } $Purchase = new Purchase($Shopp->Order->purchase); $Purchase->load_purchased(); } else { // For 1.0.x // Only process if we're in the checkout process (receipt page) if (function_exists('is_shopp_page') && !is_shopp_page('checkout')) { return $push; } // Only process if we have valid order data if (!isset($Shopp->Cart->data->Purchase)) { return $push; } if (empty($Shopp->Cart->data->Purchase->id)) { return $push; } $Purchase = $Shopp->Cart->data->Purchase; } $push[] = "'_addTrans'," . "'" . $Purchase->id . "'," . "'" . GA_Filter::ga_str_clean(get_bloginfo('name')) . "'," . "'" . number_format($Purchase->total, 2) . "'," . "'" . number_format($Purchase->tax, 2) . "'," . "'" . number_format($Purchase->shipping, 2) . "'," . "'" . $Purchase->city . "'," . "'" . $Purchase->state . "'," . "'.{$Purchase->country}.'"; // Country foreach ($Purchase->purchased as $item) { $sku = empty($item->sku) ? 'PID-' . $item->product . str_pad($item->price, 4, '0', STR_PAD_LEFT) : $item->sku; $push[] = "'_addItem'," . "'" . $Purchase->id . "'," . "'" . $sku . "'," . "'" . str_replace("'", "", $item->name) . "'," . "'" . $item->optionlabel . "'," . "'" . number_format($item->unitprice, 2) . "'," . "'" . $item->quantity . "'"; } $push[] = "'_trackTrans'"; return $push; }