Post by chrisgwynne » Tue May 21, 2019 10:06 pm

2.3.0.2

Hello

I'm trying to get the cart subtotal on the checkout page in another area besides the main shopping list total. I've tried various ways to enable this without succeeding.

I've declared

Code: Select all

$data['cart_total'] = $this->cart->getSubTotal();
in the controller and tried calling

Code: Select all

$total
, however this doesnt work and produces the error of

Code: Select all

Undefined property: Template\PHP::$cart in ... template\checkout\cart.tpl on line 107
Fatal error: Call to a member function getSubTotal() on null in ... template\checkout\cart.tpl on line 107
Any assistance?

Chris

New member

Posts

Joined
Fri Nov 11, 2016 7:33 am

Post by thekrotek » Tue May 21, 2019 10:18 pm

You can't call anything from template. Use controller instead.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member
Online

Posts

Joined
Sun Jul 03, 2016 12:24 am


Post by chrisgwynne » Wed May 22, 2019 12:43 am

Hi thanks for the reply.

As above, I declared

Code: Select all

 $data['cart_total'] = $this->cart->getSubTotal();  
in the controller.

Then in the template I tried

Code: Select all

echo $cart_total
But I was met with errors.

New member

Posts

Joined
Fri Nov 11, 2016 7:33 am

Post by thekrotek » Wed May 22, 2019 12:47 am

The error you posted disagrees with you. It clearly tells you, that the code you provided is in TPL file, not controller.

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member
Online

Posts

Joined
Sun Jul 03, 2016 12:24 am

Who is online

Users browsing this forum: Gobbo, thekrotek and 30 guests