Jump to content

Help displaying variable from module


Recommended Posts

Hi all, 

I'm trying to setup a loyalty module in prestashop 1.7. 

So far everything works however i cannot get the amount of points to show on the template discounts.tpl. I currently have this: 

Discounts: TPL

			<tr class="alternate_item">
				<td colspan="2" class="history_method bold" style="text-align:center;">{l s='Total points available:' mod='loyalty'}</td>
						<td colspan="2" class="history_method bold" style="text-align:center;">	{$points|intval}</td>
				<td class="history_method">&nbsp;</td>

 

Loyalty.php

	public function hookDisplayMyAccountBlock($params)
	{
		include_once(dirname(__FILE__).'/LoyaltyModule.php');
		include_once(dirname(__FILE__).'/LoyaltyStateModule.php');

		$customer = new Customer((int)$params['id_customer']);
		if ($customer && !Validate::isLoadedObject($customer))
			die($this->l('Incorrect Customer object.'));

		$details = LoyaltyModule::getAllByIdCustomer((int)$params['id_customer'], (int)$params['cookie']->id_lang);
		$points = (int)LoyaltyModule::getPointsByCustomer((int)$params['id_customer']);
		return $this->hookCustomerAccount($params);
	}

And i have added the module to the hook displayMyAccountBlock

any help would be greatly apprieciated.

 

Thanks

Edited by Diddlyuk (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...
On 31/03/2018 at 11:01 AM, Rho_Bur said:

use $this->context->smarty->assign( "variable", value) in your hook (or the hookHeader); then you'll be able to access it in your tpl with $variable.

 

 

I added the code below to my loyalty.php file but still no joy i'm afraid

Loyalty.php

$this->context->smarty->assign('cpoints', $points);

 

discounts.tpl

<td colspan="2" class="history_method bold" style="text-align:center;">{l s='Total points available:' mod='loyalty'}</td>
<td colspan="2" class="history_method bold" style="text-align:center;">{$cpoints|intval}</td>
<td class="history_method">&nbsp;</td>

 

what am i doing wrong?

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...