I'd recommend adding a block via XML with its own template. It'll make it a little cleaner since it won't fill up the success.phtml file.
Step 1:
In your app/design/frontend/YOUR_PACKAGE/YOUR_THEME/layout/local.xml
(This file is optional, so if you don't have one, create one)
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<!-- success page view -->
<checkout_onepage_success>
<!-- references the main body of the page -->
<reference name="content">
<block type="checkout/onepage_success" name="whatever.you.want" as="order_items" template="checkout/success/items.phtml" />
</reference>
</checkout_onepage_success>
</layout>
Step 2:
In your app/design/frontend/YOUR_PACKAGE/YOUR_THEME/template/checkout/success.phtml
file, add the following call to request the block we just created. You can place it anywhere you'd like it to show up.
<?php echo $this->getChildHtml('order_items') ?>
The order_items
references the as="order_items"
attribute in my example local.xml file, so you can change it to whatever you'd like. Just make sure to change both of them.
Step 3:
As you can see, we're referencing a phtml that doesn't exist in the template="checkout/success/items.phtml"
attribute. You need to create this file at that location. (You can change this location to whatever you'd like)
So for this example, it should be at app/design/frontend/YOUR_PACKAGE/YOUR_THEME/template/checkout/success/items.phtml
In this file we can get the items and various data from the items with something like:
<?php
/*
* joaogdesigner
* custom items for the success page
*
* @category design
* @package your_package
* @block Mage_Checkout_Onepage_Success
*
*/
$order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId());
$items = $order->getAllVisibleItems();
$total = $order->getGrandTotal(); // grand total
?>
<?php foreach( $items as $item ): ?>
Product ID: <?php echo $item->getProductId(); ?>
Name: <?php echo $item->getName(); ?>
Qty: <?php echo $item->getQtyOrdered(); ?>
Price: <?php echo $item->getPrice(); ?>
<?php endforeach; ?>
Hope this helps! Let me know if you need anything clarified.