Jump to content

newbie question: variables not forwarded by assign() to .tpl file


Recommended Posts

I am new to prestashop and smarty/php, so sorry if my question is very easy to solve.

 

I try to display the shipping cost for 2 specific carriers in the shopping cart summary section (first screen during checkout procedure).

I found out I should calculate the cost for the 2 carrier in OrderController.php and forward the result to shopping-cart.tpl through the smarty-> assign() method.

 

I tried it with calculated results, and then with values I set staticly in an array and then separatly, but it still does not work.

 

Here is my code:

 

OrderController.php > initContent() > switch "loop"

default:

$this->_assignSummaryInformations();

/* $this->context->smarty->assign(array(

'aaa' => '333',

'bbb' => 444));*/

$this->context->smarty->assign('aaa', 333);

$this->context->smarty->assign('bbb', '444');

$this->setTemplate(_PS_THEME_DIR_.'shopping-cart.tpl');

break;

 

 

Where "aaa" and "bbb" should be displayed, the cell remains blank :-(

Here is the test I wrote in the shopping-cart.tpl file:

 

<p> Before if freight</p>

{if (!$aaa)}

<p> freightshipping not set and value is:{$aaa}(blank expected)</p>

{else}

<p> freighshipping is on and has value {$aaa}</p>

{/if}

<p> After if freight</p>

 

 

<p> Before if Air</p>

{if (!$bbb)}

<p> airshipping not set and value is:{$bbb}(blank expected)</p>

{else}

<p> airshipping is on and has value {$bbb}</p>

{/if}

<p> After if air</p>

 

In both cases, the variables are shown as not being known, and so nothing is printed on screen... :-(

 

I guess it's something very simple, but I just could not figure it out so far. Sorry again if it's really simple.

Link to comment
Share on other sites

  • 4 weeks later...

Sorry for the very late answer :-/

I found my mistake. I was doing it as an override from a module. The problem was that I ad not reinstalled the module to update the overridden file in the prestashop/override folder...

newbie mistake....

 

I had not seen the email saying someone had answered, that's why I had not replied...sorry

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...