Created
September 19, 2013 12:29
-
-
Save clare485/6622725 to your computer and use it in GitHub Desktop.
Add order information to success page - for Channel Advisor script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Magento | |
* | |
* NOTICE OF LICENSE | |
* | |
* 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: | |
* http://opensource.org/licenses/afl-3.0.php | |
* 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 [email protected] so we can send you a copy immediately. | |
* | |
* DISCLAIMER | |
* | |
* 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 http://www.magentocommerce.com for more information. | |
* | |
* @category design | |
* @package inspired | |
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com) | |
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) | |
*/ | |
?> | |
<? // get order summary values for channel advisor script | |
require_once 'app/Mage.php'; | |
umask(0); | |
#Mage::run('base'); | |
//$_SERVER['SERVER_PORT']='443'; | |
Mage::app('base'); | |
//$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> | |
</div> | |
<?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()) :?> | |
<p> | |
<?php echo $this->__('Click <a href="%s" onclick="this.target=\'_blank\'">here to print</a> a copy of your order confirmation.', $this->getPrintUrl()) ?> | |
<?php echo $this->getChildHtml() ?> | |
</p> | |
<?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;?> | |
</ul> | |
<?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> | |
</div> | |
<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}]); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment