Any questions about Documents Sellers, post it here .

[MOD] - how to add prices and total to cart module

  • Richard
  • Topic Author
  • Offline
  • New Member
  • New Member
More
12 years 5 months ago #16946 by Richard
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">&#163;<?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">&#163;<?php echo $doc->price ; ?></span>

You will want to change the "&#163;" 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("&#163;" + sum.toFixed(2));

And now my cart displays like this:
The following user(s) said Thank You: alryalls

Please Log in or Create an account to join the conversation.

More
12 years 4 months ago #18134 by alryalls
awesome Richard!

I haven't tried it out yet, but this might just be what I'm looking for

Cheers mate :)

Please Log in or Create an account to join the conversation.

More
12 years 4 months ago #18189 by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: [MOD] - how to add prices and total to cart module
Thanks Richard for sharing the modification. Could you please upload the modified file here so that in case someone needs it, they can simply download the file and upload it to server ?

Regards,

Tuan

Please Log in or Create an account to join the conversation.