Jump to content

(solved) Prestashop custom module variable passed to Theme .tpl file


Recommended Posts

Im trying to pass my own variable from module to template file .tpl

I have this code that is used for displaying availability in eshop. Product.tpl

{if $product.availability == 'available'} 
	{if $product.quantity <= 0 && $product.allow_oosp} 
		{if isset($product.available_date) && $product.available_date != '0000-00-00'} <i class="fa fa-truck rtl-no-flip" aria-hidden="true"></i> 
{$product.availability_message} ({if $product.available_date|strtotime > $smarty.now}<span class="available-date">{l s='naskladnění' d='Shop.Theme.Catalog'} {$product.available_date|date_format:"%d.%m.%Y"}</span>{/if}) 
		{/if} 
	{/if}
{/if}

Then Im having my own module where im assigning value to smarty Mymodule.php

$in_stock = 1; 
$this->context->smarty->assign("is_in_stock", $in_stock);

My question is if there is any way to access my smarty variable directly from theme tpl? I need to set up another {if else} with that variable but cant access it.

When I add variable to custom hook I cant access it neither.. Or maybe I dont know how. I tried to create front controller but nothing happened.

Something like

{if isset($product.available_date) && $mymodule.is_in_stock = 1 && $product.available_date != '0000-00-00'}

php prestashop

Edited by sooly (see edit history)
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...