Reputation: 397
How can I display the $total on an external web page from opencart. The web page and opencart are on the same server but opencart is installed in a sub folder. I would like to display the Total and a link back to opencart. I have the link as follows so far:
<div id="topcart">
<p>
<span class="cartamt">$123.00</span>
<a href="/store/index.php?route=checkout/checkout"><img src="/images/icon-cart.png" alt="Cart" /></a>
</p>
</div><!-- end div topcart -->
I just need to replace the 123.00 with the actual total amount in opencart. Thanks, Robert Campbell
Upvotes: 0
Views: 2633
Reputation: 53
To anyone else trying to find this answer it's simple. Edit the system/library/cart.php
file like jay says but when getting the total use
$_SESSION['default']['currentTotal']
instead.
Upvotes: 0
Reputation: 15151
The simplest way to do this would be to save the total as getTotal()
is called in the cart class to a session variable, and then use the session variable in that page (assuming they are on the same domain and using the same session). To set the session variable, use
$this->session->data['currentTotal'] = $total;
Just before return $total;
in system/library/cart.php
. Adding currency formatting gets a little more tricky. You instead need to use
global $registry;
$this->session->data['currentTotal'] = $registry->get('currency')->format($total);
After that, in your non OC page start a session if it's not already started, and add
<?php echo empty($_SESSION['currentTotal'] ? '$0.00' : $_SESSION['currentTotal']); ?>
In the place of your $123.00
Upvotes: 2