Post by arthur » Sat Nov 11, 2017 2:43 am

Hello. I'd like to show Free shipping message in checkout/cart.tpl just under the main table. Postage is not included. Please see my code example below. I need to get $total somehow.

Code: Select all

<?php 
//$total = 120;
$sum = (100-$total);	  
if ($total >= 100) {
echo "Your are eligable for FREE SHIPPING"; }
else { 
echo  "To be eligable for free shipping you need to buy for ".$sum." more"; 
}	  
?>
OpenCart v2.3.0.2

New member

Posts

Joined
Wed Oct 25, 2017 2:14 am

Post by DigitCart » Sat Nov 11, 2017 12:42 pm

Hi,
try this:

Code: Select all

$this->cart->getTotal();
//or
$this->cart->getSubTotal();

My Extensions / DigitCart


User avatar
Active Member
Online

Posts

Joined
Thu Jun 22, 2017 5:32 pm


Post by arthur » Sat Nov 11, 2017 4:03 pm

DigitCart wrote:
Sat Nov 11, 2017 12:42 pm
Hi,
try this:

Code: Select all

$this->cart->getTotal();
//or
$this->cart->getSubTotal();
These show me the following errors:
Notice: 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


Probably it's not enough to modify the .tpl file only.

New member

Posts

Joined
Wed Oct 25, 2017 2:14 am

Post by DigitCart » Sat Nov 11, 2017 4:16 pm

Yes,
You must use them in controller.
controller:

Code: Select all

$data['cart_total'] = $this->cart->getTotal();
view:

Code: Select all

<?php echo $cart_total; ?>

My Extensions / DigitCart


User avatar
Active Member
Online

Posts

Joined
Thu Jun 22, 2017 5:32 pm


Post by arthur » Sat Nov 11, 2017 4:36 pm

DigitCart wrote:
Sat Nov 11, 2017 4:16 pm
Yes,
You must use them in controller.
controller:

Code: Select all

$data['cart_total'] = $this->cart->getTotal();
view:

Code: Select all

<?php echo $cart_total; ?>
It works ;D Thank you once again.

New member

Posts

Joined
Wed Oct 25, 2017 2:14 am

Post by DigitCart » Sat Nov 11, 2017 5:12 pm

You're welcome.

My Extensions / DigitCart


User avatar
Active Member
Online

Posts

Joined
Thu Jun 22, 2017 5:32 pm


Post by mupcku » Mon Aug 20, 2018 7:39 pm

Do you have any idea why i still cant get my cart total on tpl page? Im using 2.1.0.1

New member

Posts

Joined
Tue Jan 24, 2017 8:12 pm
Who is online

Users browsing this forum: No registered users and 2 guests