| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
pass variable from 1 template to the other | |||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
![]() I'm trying to pass a variable value from Fast_Lane_Checkout/cart_substotal.tpl. to main/cart.tpl.
I've created a variable call $newsubtotal in the template {include file="modules/Fast_Lane_Checkout/cart_substotal.tpl" newsubtotal2=$newsubtotal1} like this: {math equation="subtotal+ship" subtotal=$cart.display_discounted_subtotal ship=$upsship assign=newsubtotal}{include file="currency.tpl" value=$newsubtotal} I want to pass the $newsubtotal value to the main/cart.tpl. I tried using the include command: {include file="modules/Fast_Lane_Checkout/cart_substotal.tpl" newsubtotal1=$newsubtotal} , but the newsubtotal1 is blank. Can someone help with this? Thanks!
__________________
x-cart 4.1.12 x-cart 4.2 |
|||||||
#2
|
|||||||||
|
|||||||||
![]() As a last resort you can use PHP "global". declare the variable as global in both functions then you can see and modify it in both.
__________________
Richard Williams Rogue Wave Limited Initial Inventory Imports Daily Inventory Updates Daily Inventory Reports Drop Ship Support Order Export to Shipper/Supplier Shopping Feeds That Work Programming for X-Cart richard@roguewavelimited.com http://www.roguewavelimited.com |
|||||||||
#3
|
|||||||
|
|||||||
![]() Thanks. - Can you show me an example?
__________________
x-cart 4.1.12 x-cart 4.2 |
|||||||
#4
|
|||||||||
|
|||||||||
![]() In cart_subtotal.tpl you get the smarty var value $newsubtotal and put it in a global php var $phpnewsubtotal.
Code:
Then in cart.tpl you get the value from the php global var and put it in the smarty var. Code:
That's it I think. Be warned there is probably a more conventional way to do this as you will no doubt find out in subsequent replys by other folks.
__________________
Richard Williams Rogue Wave Limited Initial Inventory Imports Daily Inventory Updates Daily Inventory Reports Drop Ship Support Order Export to Shipper/Supplier Shopping Feeds That Work Programming for X-Cart richard@roguewavelimited.com http://www.roguewavelimited.com |
|||||||||
#5
|
|||||||
|
|||||||
![]() It doesn't seem to like the php code for the cart_subtotal.tpl - it just echo's out:
global $phpnewsubtotal; $phpnewsubtotal = $smarty->get_template_vars('newsubtotal'); I put the php code in cart.tpl at the top of the page and that seemed to be ok, but no matter where I put the php code for cart_subtotal.pl it won't execute.
__________________
x-cart 4.1.12 x-cart 4.2 |
|||||||
#6
|
|||||||||
|
|||||||||
![]() cart_subtotal is a tpl file right? not a php file?
Should work fine. Maybe someone else could help.
__________________
Richard Williams Rogue Wave Limited Initial Inventory Imports Daily Inventory Updates Daily Inventory Reports Drop Ship Support Order Export to Shipper/Supplier Shopping Feeds That Work Programming for X-Cart richard@roguewavelimited.com http://www.roguewavelimited.com |
|||||||||
#7
|
|||||||
|
|||||||
![]() Quote:
$smarty->get_template_vars('newsubtotal'); with $this->get_template_vars('newsubtotal');
__________________
X-Cart Gold 4.2.2 - 3.1.19 |
|||||||
#8
|
|||||||
|
|||||||
![]() Also should be
{/php}
__________________
X-Cart Gold 4.2.2 - 3.1.19 |
|||||||
#9
|
|||||||
|
|||||||
![]() Thanks! I can't believe I missed that backslash. I'll give that a go.
I did come up with another way in the meanwhile. It's kind of hack... from a response to the question I posed in the smarty forum: After I assigned $newsubtotal in the cart_subtotal, I captured the value: {capture name="mytotal"}{$newsubtotal}{/capture} then in cart.tpl I used: {include file="currency.tpl" value=$smarty.capture.mytotal}
__________________
x-cart 4.1.12 x-cart 4.2 |
|||||||
![]() |
|
Thread Tools | Search this Thread |
|
|
|
|||
X-Cart forums © 2001-2020
|