Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Show total price on grouped product page? 
 
wanghan
Jr. Member
 
Total Posts:  1
Joined:  2011-02-05
 

I have created a Grouped Product with 4 items in it. Through some coding I was able to display the total price (max price or total sum) on the list page (see screen #1). However, I am having troubles showing that same price on the grouped product page (see screen #2). I have tried repurposing the code I used for the list page, but to no avail.

Since my quantities are not configurable, I just want to the total sum displayed.

The following is what I changed in price.phtml to get the display on the list page:

<?php
                $sum 
$max 0;
                
                
$products $_product->getTypeInstance()->getAssociatedProducts();
                foreach (
$products as $product){
                    $sum 
+= $product->getPrice();
                    
$max max($max$product->getPrice());
                
}
                
               
?>
             
<span class="price"><?php echo $this->__('') . $_coreHelper->currency($sumtruefalse); ?></span>

Any assistance would be MUCH appreciated!

Thanks in advance!

 
Magento Community Magento Community
Magento Community
Magento Community
 
aklo
Jr. Member
 
Total Posts:  25
Joined:  2010-11-09
 

Can I ask what code you used to display the total sum in the list page? And did you manage to solve the issue in the grouped page?
I’m also working with grouped products, like a giftbox. So product quantities can’t be changed, so price is always the same…

Would appreciate it if you could help me out!

Thanks,
Annemieke

 
Magento Community Magento Community
Magento Community
Magento Community
 
fust
Jr. Member
 
Total Posts:  2
Joined:  2012-12-19
 

Just in case anyone is still wondering how to do this i’ll post my solution.

For the product list edit the catalog/product/list.phtml file and replace

<?php echo $this->getPriceHtml($_producttrue?>
with
<?php if ($_product->getData('type_id') == 'grouped'):?>
                        <?php $_associatedProducts 
$_product->getTypeInstance()->getAssociatedProducts(); ?>
                        <?php $_hasAssociatedProducts 
count($_associatedProducts) > 0?>
                        <?php 
if ($_hasAssociatedProducts): ?>
                        <?php $sum 
0;?>
                        <?php 
foreach ($_associatedProducts as $_item): ?>
                                <?php $sum 
+= $_item->getPrice();?>
                        <?php 
endforeach; ?>
                        
<div class="price-box">
                            <
class="minimal-price">
                                <
span class="price-label">Begint bij:</span>
                                <
span class="price">&euro;&nbsp;<?php echo $sum?></span>
                            </
p>
                        </
div>
                    
<?php else: ?>
                    <?php 
echo $this->getPriceHtml($_producttrue?>
                    <?php 
endif;?>
                    <?php 
else: ?>
                    <?php 
echo $this->getPriceHtml($_producttrue?>
                    <?php 
endif;?>
(I know, I should’ve used the currency view helper but this was a quick ‘n’ dirty fix)

For the product page edit catalog/product/type/grouped.phtml and replace lines 61 - 83 with this:

<?php $sum 0;?>
    <?php 
foreach ($_associatedProducts as $_item): ?>
        <?php $_finalPriceInclTax 
$this->helper('tax')->getPrice($_item$_item->getFinalPrice(), true?>
        
<tr>
            <
td><?php echo $this->htmlEscape($_item->getName()) ?></td>
            
<?php if ($this->getCanShowProductPrice($_product)): ?>
            
<td class="a-right">
                
<?php if ($this->getCanShowProductPrice($_item)): ?>
                <?php 
echo $this->getPriceHtml($_itemtrue?>
                <?php 
echo $this->getTierPriceHtml($_item?>
                <?php 
endif; ?>
            
</td>
            
<?php endif; ?>
            <?php 
if ($_product->isSaleable()): ?>
            
<td class="a-center">
            
<?php if ($_item->isSaleable()) : ?>
                
<input type="text" name="super_group[<?php echo $_item->getId() ?>]" maxlength="12" value="<?php echo $_item->getQty()*1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
            
<?php else: ?>
                
<class="availability out-of-stock"><span><?php echo $this->__('Out of stock'?></span></p>
            
<?php endif; ?>
            
</td>
            
<?php endif; ?>
            <?php $sum 
+= $_item->getPrice();?>
        
</tr>
    
<?php endforeach; ?>
    
<tr><td>Totaal:</td><td class="a-right">
        <
span class="price">&euro;&nbsp;<?php echo $sum?></span>
    </
td>

Note: this is for magento 1.6.1. Don’t know if it will work with other versions too.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top