Show Price Total of Wishlist Including Options and Quantities in Magento 1.9

magento-1.9wishlist

I want to set my Magento wishlist page up to resemble a quote page. In order to do that, I need to show the total of all the line items in the wishlist including the configured price and the quantities. Right now, I am able to produce a Total but it does not include the product options, it only grabs the product base price.

app/design/frontend/…/…/template/wishlist/item/list.phtml

<?php
    $columns = $this->getColumns();
    $wishlistTotal = 0;
?>

<ol id="products-wishlist-list" class="products-list wishlist-list">
    <?php if (count($this->getItems())): ?>
        <?php foreach ($this->getItems() as $item): ?>
        <li class="item" id="item_<?php echo $item->getId();?>">
            <?php $i = 0; $count = count($columns);
            foreach ($columns as $column):
                $column->setItem($item);

                if ($i === 1) :
                    echo '<div class="product-shop">';
                endif;

                echo $column->toHtml($item);

                if (++$i === $count) :
                    echo '</div>';
                $_product = $item->getProduct();
        $options = false;
        if ($optionsBlock = $this->getChild('customer.wishlist.item.options')) {
            $options = $optionsBlock
                ->setItem($item)
                ->getConfiguredOptions();
        }
        $wishlistTotal = $wishlistTotal + ($_product->getPrice($_product, empty($options)) * $item->getQty());
        //echo $item->getPrice();

                endif;
            endforeach; ?>
        </li>
        <?php endforeach ?>
    <?php else: ?>
        <li class="wishlist-empty"><?php echo $this->__('This Wishlist has no Items');?></li>
    <?php endif; ?>
<?php 
    echo '<li class="item even last"><div class="product-shop">';
    echo '<h3 style="float:right;">Wishlist Total: $' .number_format($wishlistTotal, 2, '.', ','). '</h3>';
    echo '</div></li>';
?>
</ol>

<?php foreach ($columns as $column): ?>
    <?php echo $column->getAdditionalHtml();?>
<?php endforeach; ?>
<script type="text/javascript">
//<![CDATA[
    decorateList('products-wishlist-list', 'none-recursive');

<?php foreach ($columns as $column): ?>
    <?php echo $column->getJs();?>
<?php endforeach; ?>
//]]>
</script>

If there's an easier way to do this, please let me know. Otherwise, I'd like help figuring out how to show the wishlist total including quantities and item total prices. Thanks in advance!

Magento 1.9.1

Best Answer

Instead of this:

$wishlistTotal = $wishlistTotal + ($_product->getPrice($_product, empty($options)) * $item->getQty());

Use this:

$wishlistTotal = $wishlistTotal + ($_product->getFinalPrice() * $item->getQty());

Final Result:

<?php
    $columns = $this->getColumns();
    $wishlistTotal = 0;
?>

<ol id="products-wishlist-list" class="products-list wishlist-list">
    <?php if (count($this->getItems())): ?>
        <?php foreach ($this->getItems() as $item): ?>
        <li class="item" id="item_<?php echo $item->getId();?>">
            <?php $i = 0; $count = count($columns);
            foreach ($columns as $column):
                $column->setItem($item);

                if ($i === 1) :
                    echo '<div class="product-shop">';
                endif;

                echo $column->toHtml($item);

                if (++$i === $count) :
                    echo '</div>';
                $_product = $item->getProduct();
        $wishlistTotal = $wishlistTotal + ($_product->getFinalPrice() * $item->getQty());

                endif;
            endforeach; ?>
        </li>
        <?php endforeach ?>
    <?php else: ?>
        <li class="wishlist-empty"><?php echo $this->__('This Wishlist has no Items');?></li>
    <?php endif; ?>
<?php 
    echo '<li class="item even last"><div class="product-shop">';
    echo '<h3 style="float:right;">Wishlist Total: $' .number_format($wishlistTotal, 2, '.', ','). '</h3>';
    echo '</div></li>';
?>
</ol>

<?php foreach ($columns as $column): ?>
    <?php echo $column->getAdditionalHtml();?>
<?php endforeach; ?>
<script type="text/javascript">
//<![CDATA[
    decorateList('products-wishlist-list', 'none-recursive');

<?php foreach ($columns as $column): ?>
    <?php echo $column->getJs();?>
<?php endforeach; ?>
//]]>
</script>