Greetings,
I am trying to get the total value of the order including shipping and discounts.
I have been using $this->cart->getTotal() and I am getting the value of the cart, but without the shipping and discounts.
What is the function i need to use or what should I edit to get the total value of the order.
Thanks
Thanks Johnathan, but I found my problem is far to be solved.
I thought I had a porting with the subtotal, but I am back to zero again. When I echo the total in the success.tpl it echo 0.
This is what I have done so far. Opencart 1.5.5.1
catalog/controller/checkout/success.php
And in catalog/controller/checkout/success.tpl
In the end user success code Im getting echo "0", not even the subtotal.
I have also tried to get the order ID, but it gives me 0 as well. If I delete $this->data['total'] = 0; I will get the subtotal value only one time, after that I gives me error: undefined variable.
Any ideas?
I thought I had a porting with the subtotal, but I am back to zero again. When I echo the total in the success.tpl it echo 0.
This is what I have done so far. Opencart 1.5.5.1
catalog/controller/checkout/success.php
Code: Select all
public function index() {
$this->data['order_id'] = 0; // <-- NEW LINE
$this->data['total'] = 0; // <-- NEW LINE
if (isset($this->session->data['order_id'])) {
$this->data['order_id'] = $this->session->data['order_id']; // <-- NEW LINE
$this->data['total'] = $this->cart->getTotal(); // <-- NEW LINE
$this->cart->clear();
Code: Select all
<?php if (isset($this->request->get['route']) && $this->request->get['route'] == 'checkout/success') { ?>
<!-- Facebook Conversion Code for TN Checkout -->
<script>(function() {
var _fbq = window._fbq || (window._fbq = []);
if (!_fbq.loaded) {
var fbds = document.createElement('script');
fbds.async = true;
fbds.src = '//connect.facebook.net/en_US/fbds.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(fbds, s);
_fbq.loaded = true;
}
})();
window._fbq = window._fbq || [];
window._fbq.push(['track', 'xxxx', {'value':'<?php echo $total; ?>','currency':'USD'}]);
</script>
<noscript><img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/tr?ev=xxxxx&cd[value]=0&cd[currency]=USD&noscript=1" /></noscript>
<?php } ?>
I have also tried to get the order ID, but it gives me 0 as well. If I delete $this->data['total'] = 0; I will get the subtotal value only one time, after that I gives me error: undefined variable.
Any ideas?
Not sure...your code looks correct, so it seems like it should be working.
Note that the cart is cleared after a single load of the page, so it's only going to work for an order once. You'll need to place a new order every time, or comment out the code that clears the session data.
Beyond that, I'm not sure what to suggest, except to double-check that you don't have vQmod installed and something modifying that file. Perhaps someone else will see something that I've missed.
Note that the cart is cleared after a single load of the page, so it's only going to work for an order once. You'll need to place a new order every time, or comment out the code that clears the session data.
Beyond that, I'm not sure what to suggest, except to double-check that you don't have vQmod installed and something modifying that file. Perhaps someone else will see something that I've missed.
Who is online
Users browsing this forum: No registered users and 190 guests