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


i had added product calculated 2 attributes , uses own calculated price. problem had rewrite grandtotal , subtotal calculation... example overwritting stuff.

i hope here @stackoverflow magento guru had solved problem :-)

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

but have problem /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 own calculation ? figured out 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 source code file there mentation of "mage_tax_block_checkout_grandtotal"

i looked @ /app/code/core/mage/tax/block/checkout/grandtotal.php commented lines out... nothing changed...

i hope explain me shopping-cart calculation "hidden", need foreach totals build.

i looked @ /app/code/core/mage/checkout/block/cart/totals.php

i found rendertotal ... no solution of getting foreach loop of items, wanna use

            $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 simple products load

public function rendertotal($total, $area = null, $colspan = 1) {     $code = $total->getcode();      if ($total->getas()) {         $code = $total->getas();     }     return $this->_gettotalrenderer($code)         ->settotal($total)         ->setcolspan($colspan)         ->setrenderingarea(is_null($area) ? -1 : $area)         ->tohtml(); } 

no need rewrite file. example, need change calculation of subtotal create custom module , 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 model class below

class namespace_modulename_model_quote_address_total_subtotal extends mage_sales_model_quote_address_total_subtotal { } 

copy _inititem() function parent class , paste on above created model , change calculation per need.

hope useful you!!


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -