Example #1
0
 /**
  * Retrieve Order Data HTML
  *
  * @return string
  **/
 public function getOrderHtml()
 {
     if (!Mage::helper('googleanalyticsplus')->getGoogleanalyticsplusStoreConfig('convertcurrencyenabled')) {
         return parent::getOrderHtml();
     }
     $order = $this->getOrder();
     if (!$order) {
         return '';
     }
     if (!$order instanceof Mage_Sales_Model_Order) {
         $order = Mage::getModel('sales/order')->load($order);
     }
     if (!$order) {
         return '';
     }
     $address = $order->getBillingAddress();
     $html = '<script type="text/javascript">' . "\n";
     $html .= "//<![CDATA[\n";
     $html .= '_gaq.push(["_addTrans",';
     $html .= '"' . $order->getIncrementId() . '",';
     $html .= '"' . $order->getAffiliation() . '",';
     $html .= '"' . Mage::helper('googleanalyticsplus')->convert($order, 'getBaseGrandTotal') . '",';
     $html .= '"' . Mage::helper('googleanalyticsplus')->convert($order, 'getBaseTaxAmount') . '",';
     $html .= '"' . Mage::helper('googleanalyticsplus')->convert($order, 'getBaseShippingAmount') . '",';
     $html .= '"' . $this->jsQuoteEscape($address->getCity(), '"') . '",';
     $html .= '"' . $this->jsQuoteEscape($address->getRegion(), '"') . '",';
     $html .= '"' . $this->jsQuoteEscape($address->getCountry(), '"') . '"';
     $html .= ']);' . "\n";
     foreach ($order->getAllItems() as $item) {
         if ($item->getParentItemId()) {
             continue;
         }
         $html .= '_gaq.push(["_addItem",';
         $html .= '"' . $order->getIncrementId() . '",';
         $html .= '"' . $this->jsQuoteEscape($item->getSku(), '"') . '",';
         $html .= '"' . $this->jsQuoteEscape($item->getName(), '"') . '",';
         $html .= '"' . $item->getCategory() . '",';
         $html .= '"' . Mage::helper('googleanalyticsplus')->convert($order, 'getBasePrice', $item) . '",';
         $html .= '"' . $item->getQtyOrdered() . '"';
         $html .= ']);' . "\n";
     }
     $html .= '_gaq.push(["_trackTrans"]);' . "\n";
     $html .= '//]]>';
     $html .= '</script>';
     return $html;
 }