I wanted to add the prices of items and a running total to the mini cart module.
Just wanted to share in case anyone else wanted to do the same...
Adding the price of individual items is easy:
In root/modules/mod_dms_cart/tmpl/default.php at around line 23 you should see
Code:
<a href="<?php echo $link; ?>"><?php echo $doc->title ; ?></a>
simply add
Code:
<span style="float:right;" id="ind_price">£<?php echo $doc->price ; ?></span>
straight after so the whole line reads:
Code:
<a href="<?php echo $link; ?>"><?php echo $doc->title ; ?></a> <span style="float:right;" id="ind_price">£<?php echo $doc->price ; ?></span>
You will want to change the "£" to your own currency symbol.
For the running total, I'm using jQuery Calculation Plug-in from
here
which is released under MIT and GPL licence.
Whilst you're on the cart page, add this code just above the checkout button table row:
Code:
<tr>
<td style="padding-top:8px;">
<span style="float:left;">Total:</span><span style="float:right;" id="total_price"></span>
</td>
</tr>
This will be where the running total displays.
You will need to add the .js file and code to the <head> section of your main template page rather than the cart module page...
I'm using a yootheme template, so I added it to templates/yoo_theme/layouts/template.php
So add a reference to the js file
Code:
<scr ipt type="text/javascript" src="/templates/yoo_theme/js/jquery.calculation.min.js"></sc ript>
to the head section.
Then add the following to your own document ready chain or as javascript block in the head section:
Code:
//cart total
var sum = $("[id^=ind_price]").sum();
$("#total_price").html("£" + sum.toFixed(2));
And now my cart displays like this: