1

I am using OpenCart 2.3.0.2 . I'm trying to display the total from checkout/cart.tpl to the checkout/checkout.tpl but when i use the code from cart page it doesn't work:

<div class="row">
    <div class="col-sm-4 col-sm-offset-8">
      <table class="table table-bordered">
        <?php foreach ($totals as $total) { ?>
        <tr>
          <td class="text-right"><strong><?php echo $total['title']; ?>:</strong></td>
          <td class="text-right"><?php echo $total['text']; ?></td>
        </tr>
        <?php } ?>
      </table>
    </div>
  </div>

The problem is that I don't know how to get the total price as a variable.

Vy Do
  • 46,709
  • 59
  • 215
  • 313

1 Answers1

0
At file checkout.php $data['total'] = $this->cart->getTotal();
At file checkout.tpl echo $total
MD. Khairul Basar
  • 4,976
  • 14
  • 41
  • 59
Santosh Patel
  • 549
  • 2
  • 13
  • 1
    Thank you for this code snippet, which might provide some limited, immediate help. A proper explanation [would greatly improve](//meta.stackexchange.com/q/114762) its long-term value by showing *why* this is a good solution to the problem, and would make it more useful to future readers with other, similar questions. Please [edit] your answer to add some explanation, including the assumptions you've made. – Toby Speight Sep 22 '17 at 10:39
  • Didn't work. Notice: Undefined variable: totals in /home/zonad037/public_html/catalog/view/theme/tt_oregon1/template/checkout/checkout.tpl on line 114Warning: Invalid argument supplied for foreach() in /home/zonad037/public_html/catalog/view/theme/tt_oregon1/template/checkout/checkout.tpl on line 114 – Rafael Prado Sep 22 '17 at 18:45
  • did you add first line in checkout.php ?? – Santosh Patel Sep 25 '17 at 06:54