9/19/2013 - 12:29 PM

Add order information to success page - for Channel Advisor script

Add order information to success page - for Channel Advisor script

 * Magento
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to so we can send you a copy immediately.
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to for more information.
 *  @category    design
 *  @package     inspired
 *  @copyright   Copyright (c) 2012 Magento Inc. (
 *  @license  Academic Free License (AFL 3.0)

<? // get order summary values for channel advisor script
require_once 'app/Mage.php';



//$order = Mage::getModel('sales/order')->load(36);
$order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());  

foreach ($order->getAllItems() as $item) {

        $productArray[] = array(
                "product_sku" => $item->getSku(),
                "product_magento_id" => $item->getProductId(),
                "product_name" => $item->getName(),
                "product_qty" => $item->getQtyOrdered(),
                "product_price" => $item->getPrice(),
                "product_discount_amount" => $item->getDiscountAmount(),
                "product_row_price" => $item->getPrice() - $item->getDiscountAmount(),

<?php  // get order total for channel advisor script

$sOrderId = Mage::getSingleton('checkout/session')->getLastOrderId();
$oOrder = Mage::getModel('sales/order')->load($sOrderId);
$order1 = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId()); 
echo $oOrder->getGrandTotal();


<div class="page-title">
    <h1><?php echo $this->__('Your order has been received.') ?></h1>
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
<h2 class="sub-title"><?php echo $this->__('Thank you for your purchase!') ?></h2>

<?php if ($this->getOrderId()):?>
<?php if ($this->getCanViewOrder()) :?>
    <p><?php echo $this->__('Your order # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getViewOrderUrl()), $this->escapeHtml($this->getOrderId()))) ?></p>
<?php  else :?>
    <p><?php echo $this->__('Your order # is: %s.', $this->escapeHtml($this->getOrderId())) ?></p>
<?php endif;?>
    <p><?php echo $this->__('You will receive an order confirmation email with details of your order and a link to track its progress.') ?></p>
<?php if ($this->getCanViewOrder() && $this->getCanPrintOrder()) :?>
        <?php echo $this->__('Click <a href="%s" onclick="\'_blank\'">here to print</a> a copy of your order confirmation.', $this->getPrintUrl()) ?>
        <?php echo $this->getChildHtml() ?>
<?php endif;?>
<?php endif;?>

<?php if ($this->getAgreementRefId()): ?>
    <p><?php echo $this->__('Your billing agreement # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getAgreementUrl()), $this->escapeHtml($this->getAgreementRefId())))?></p>
<?php endif;?>

<?php if ($profiles = $this->getRecurringProfiles()):?>
<p><?php echo $this->__('Your recurring payment profiles:'); ?></p>
<ul class="disc">
<?php foreach($profiles as $profile):?>
<?php $profileIdHtml = ($this->getCanViewProfiles() ? sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getProfileUrl($profile)), $this->escapeHtml($this->getObjectData($profile, 'reference_id'))) : $this->escapeHtml($this->getObjectData($profile, 'reference_id')));?>
    <li><?php echo $this->__('Payment profile # %s: "%s".', $profileIdHtml, $this->escapeHtml($this->getObjectData($profile, 'schedule_description')))?></li>
<?php endforeach;?>
<?php endif;?>

<div class="buttons-set">
    <button type="button" class="button" title="<?php echo $this->__('Continue Shopping') ?>" onclick="window.location='<?php echo $this->getUrl() ?>'"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>

<script type="text/javascript">
    // channel advisor script
    var _caq = _caq || [];
    var products = [];
    products.push({Sku: '<?php echo $item->getSku() ?>', UnitPrice: '<?php echo $item->getPrice(); ?>', Quantity: '<?php echo $item->getQtyOrdered() ?>'});
    products.push({Sku: '<?php echo $item->getSku() ?>', UnitPrice: '<?php echo $item->getPrice(); ?>', Quantity: '<?php echo $item->getQtyOrdered() ?>'});
    _caq.push(["Order", {OrderId: '<?php echo $this->getOrderId() ?>', Revenue: '<?php echo $oOrder->getGrandTotal(); ?>', CurrencyCode: 'GBP', Products: products}]);