cancel
Showing results for 
Search instead for 
Did you mean: 

how magento 1.9.2.4 update the cart total (Need to understand functionality to make changes)

how magento 1.9.2.4 update the cart total (Need to understand functionality to make changes)

Please tell me How your framework update the cart Grand total on the fly.As I noticed that it is embedding a span element when executing this code.

app/design/frontend/(mywebfolder)/default/template/page/html/minicart.phtml

 

$cart_summary_qty = Mage::getSingleton('checkout/cart')->getSummaryQty();$cart_summary_qty = !empty($cart_summary_qty)?$cart_summary_qty:0;$cart_subtotal = Mage::helper('ves_tempcp')->getCartSubtotal();$cart_total = Mage::helper("ves_tempcp")->__("%s ITEM - %s");$cart_total = sprintf($cart_total, $cart_summary_qty, $cart_subtotal);

?>

<div id="cart" class="clearfix">
        <div class="heading">
            <div class="cart-inner">
                <a href="javascript&colon;;" class="shopping-cart-icon"> 
                    <span class="hidden">&nbsp;</span>
                </a>
                <div class="cart-total">
                    <h3>Shopping Cart</h3>
                    <a href="javascript&colon;;" id="cart-total"><?php echo $cart_total; ?> </a>
                </div>
            </div>
        </div>

 

What i noticed that this part of code is updating the cart without refresh or say it as with ajax call.

<a href="javascript&colon;;" id="cart-total"><?php echo $cart_total; ?> </a>

what I wants to know is that , I have spend a whole day to search the file from where this piece of code is generating the span element because I wants to customize it but failed.I am unable to find the source from where it is generated like this in inspect element.

<a href="javascript&colon;;" id="cart-total">3 ITEM - <span class="price">$9.40</span> </a>

I want to use the total amount/$cart_total into another element but the problem i got is that I am unable get update on the fly on the other element , what I think that it is because of id attribute used instead of class to update the cart, so unable to update on the fly/with ajax on the same page with similar ids.So what is the solution to this problem.how can I use the total amount again on the same page and upadate on the fly as my previous element is doing.

 

3 REPLIES

Re: how magento 1.9.2.4 update the cart total (Need to understand functionality to make changes)

Hi @Shahgsahab1,



Unfortunately, the code that you provided as example is not the default from Magento 1.9.2.4.

 

Since that is a custom solution that has been built in your store, there is no way to tell exactly the location of the code that generates those values.

 

Have you installed a custom extension for the checkout or are there major customizations in your shopping cart page?



Best regards.
Gabriel

If my answer was useful, please give "Kudos" to this post.
If my answer helps you to resolve the problem, click on "Accept as Solution".

Re: how magento 1.9.2.4 update the cart total (Need to understand functionality to make changes)

Hi @Shahgsahab1

 

Magento have 'collect' function to calculate G.T. in

Mage_Sales_Model_Quote_Address_Total_Abstract

if you wants to do some stuff you can override the collect method.

If you wants to get value of grand total here is the code :

$quote = Mage::getModel('checkout/session')->getQuote();
$quoteData= $quote->getData();
$grandTotal=$quoteData['grand_total'];

 

Let me know if it helps. You can raise a KUDOS if its really worth for you. Also if it solves your problem then please mark as SOLUTION.

Re: how magento 1.9.2.4 update the cart total (Need to understand functionality to make changes)

Thanks for your response.

 

Yes there is a lot of customization in shopping cart.And I have found the Jquery function which is called from ajax when user add an item to the cart.That ajax call is doing a trick to update it on the fly.