开发者

Magento howto fetch / change / overwrite the totals.phtml calculation?

i had added a product that is calculated by two attributes and uses a own calculated price. the problem is that i had to rewrite the grandtotal and subtotal calculation... for example with overwritting the stuff.

i hope here @stackoverflow is a magento guru that had solved my problem :-)

i had changed the /app/design/frontend/default/gutlauf/template/checkout/cart/item/default.phtml where the layout of the cart items is done.

but now i have a problem with /app/design/frontend/default/gutlauf/template/checkout/cart/totals.phtml

<table id="shopping-cart-totals-table">
    <col />
    <col width="1" />
    <tfoot>
        <?php echo $this->renderTotals('footer'); ?>
    </tfoot>
    <tbody>
        <?php echo $this->renderTotals(); ?>
    </tbody>
</table>

how can i get my own calculation ? i figured out that the blocks

tax/checkout_grandtotal tax/checkout_subtotal tax/checkout_tax

for example /app/design/frontend/default/gutlauf/template/tax/checkout/grandtotal.phtml

<?php echo $this->helper('checkout')->formatPrice($this->getTotal()->getValue()) ?>

according to the source code file there is a mentation of "Mage_Tax_Block_Checkout_Grandtotal"

i looked at /app/code/core/Mage/Tax/Block/Checkout/Grandtotal.php commented some lines out... but nothing changed...

i hope someone could explain to me where the shopping-cart calculation is "hidden", i need a foreach where the totals are build.

i also looked at /app/code/core/Mage/Checkout/Block/Cart/Totals.php

i found the renderTotal ... no nowhere the solution of getting the foreach loop of the items, where i wanna use something like

            $productIds = array(); 
            $productIds[] = $_item['product_id'];

            $products = Mage::getModel('catalog/product')->getCollection() 
            ->addAttributeToSelect('gl_special') 
            ->addMinimalPrice() 
            ->addStoreFilter() 
            ->addIdFilter($productIds);

            $product = $products->getItemById($_item['product_id']);
            #print_r($product);
            $bBerechnet = $product->getData('gl_special');


$childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null, $product);

to get the simple products which i load with

public function renderTotal($total, $area = null, $colspan = 1)
{
    $code = $total->getCode();

    if ($total->getAs()) {
        $code = $tota开发者_如何学运维l->getAs();
    }
    return $this->_getTotalRenderer($code)
        ->setTotal($total)
        ->setColspan($colspan)
        ->setRenderingArea(is_null($area) ? -1 : $area)
        ->toHtml();
}


No need to rewrite the file. For example, you need to change calculation of your subtotal then create custom module and put below code inside global tag of module's config.xml file

     <sales>
        <quote>
            <totals>
                <subtotal><class>modulename/sales_quote_address_total_subtotal</class></subtotal>
            </totals>
        </quote>
    </sales>

so your model class look like below

class Namespace_Modulename_Model_Quote_Address_Total_Subtotal extends Mage_Sales_Model_Quote_Address_Total_Subtotal { }

Copy _initItem() function from parent class and paste on above created model and change calculation as per you need.

Hope its useful for you!!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜