kinkibcn Posted July 13, 2016 Share Posted July 13, 2016 (edited) Hi, I'm using PS 1.6.1.5 and I need help because I've created a variable in a tpl and need to pass its value to other tpl. I searched all over Google and done endless trials without success.In the template file shopping-cart-product-line.tpl I have created a variable as follows:{assign var='cajita_regalo' value='no' scope='global'} {if strstr($product.attributes, 'Cajita regalo y tarjeta con un mensaje : Sí') } {assign var='cajita_regalo' value='si' scope='global'}{/if} The goal is that when the variable {cajita_regalo} has the value "no" the option to add a message is unchecked in file order-carrier.tplThe problem is that I can not pass the value of the variable { cajita_regalo} to order-carrier.tplDoes anyone know how to do it ?Thanks in advance for your help. Edited July 14, 2016 by kinkibcn (see edit history) Link to comment Share on other sites More sharing options...
rocky Posted July 14, 2016 Share Posted July 14, 2016 I think you'd be better off assigning the variable in an override instead of creating it in a TPL file and trying to access it in another. For example, assuming you're using one-page-checkout, create override/controllers/front/OrderOpcController.php and override the function that calls order-carrier.tpl. You can use $this->context->cart->getProducts() to get the cart products, then check if the attributes of any of the products is 'Cajita regalo y tarjeta con un mensaje : Sí', then use $this->context->smarty->assign('cajita_regalo', 'no'); if so. 1 Link to comment Share on other sites More sharing options...
kinkibcn Posted July 14, 2016 Author Share Posted July 14, 2016 Hi rocky, Thanks for your help because I was in a wrong way. I have followed your comments an now is solved and working . Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now