Magento: Display related products block on the Onepage checkout

This CodeLet display related products of cart items on the Onepage Checkout at the bottom.

Follow steps to add related products on the Onepage checkout page.

1.) Edit the onepage.phtml file located at /app/design/frontend/default/your_template/template/checkout

2.) Add the following code end of the file:

CodeLet: 

<?php
$cart = Mage::getModel('checkout/cart')->getQuote();
$array_added_product = array();
$total_product= "";
$last_product= "";
?>

<?php foreach($cart->getAllItems() as $_item):
$array_added_product[]=$_item->getProductId();?>
<?php endforeach ?>

<?php
//print_r($array_added_product);
$total_product=sizeof($array_added_product);
//echo "".$total_product;
if($total_product > 0){
$last_product=$array_added_product[($total_product-1)];
}
?>

<?php
$nProducts = $total_product;
$_product = Mage::getModel('catalog/product')->load($total_product-1);
$ids = array();
while ((count($ids) < 5) && ($nProducts > 0)){
$nProducts --;
$last_product=$array_added_product[($nProducts)];
$_product1 = Mage::getModel('catalog/product')->load($last_product);

if (!$_product1->hasRelatedProductIds()) {
foreach ($_product1->getRelatedProducts() as $product) {
if (count($ids) < 5) $ids[] = $product->getId();
else break;
}
$_product->setRelatedProductIds($ids);
}
}
?>

<?php $product_per_row=5; //how many product show in a row ?>

#dbdbdb;">

">Related Items

<?php
$product_counter=0;
foreach ($_product->getData('related_product_ids') as $r_productid) {
$_product = Mage::getModel('catalog/product')->load($r_productid);
?>

<?php if(($product_counter%$product_per_row)==0){ ?>

<?php } ?>

getProductUrl() ?>" style="text-decoration:none;margin-left:30px;text-align:center;">
init($_product, 'thumbnail')->resize(50, 50); ?>" alt="<?php echo $this->htmlEscape($_product['name']); ?>" border="0" width="50" />

getProductUrl() ?>" style="text-decoration:none; font-size:11px; color:; font-weight:bold; text-align:left; ">

<?php
if (strlen($this->helper('catalog/output')->productAttribute($_product, $_product->getName(), 'name')) > 32) {echo substr($this->helper('catalog/output')->productAttribute($_product, $_product->getName(), 'name'),0,32)."...";}
else echo $this->helper('catalog/output')->productAttribute($_product, $_product->getName(), 'name');
?>

#6b6a6a; font-weight:bold; text-align:left;margin-top:7px;">
List:<?php $price_mine= (float) $_product->getPrice();
$price_mine= number_format($price_mine,2);
?>
<?php echo "$". $price_mine; ?>

#ff5907; font-weight:bold; text-align:left;">
Our Price:<?php $final_price= (float) $_product->getFinalPrice();
$final_price= number_format($final_price,2);
?>
<?php echo "$". $final_price; ?>

#959595;">
getProductUrl() ?>" title="more info">more info

<?php
$product_counter++;
if(($product_counter%$product_per_row)==0){
?>

<?php } ?>
<?php } ?>

Is CodeLet useful?: 

Compatibility: