Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Passing Smarty variable to PHP

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 05-02-2005, 02:49 PM
 
Jeremy.Freeman Jeremy.Freeman is offline
 

Advanced Member
  
Join Date: Mar 2005
Posts: 79
 

Default Passing Smarty variable to PHP

When the registration form is submitted (or anywhere on or before the final checkout page) the page needs to execute a php script that will pass the currently set Smarty variables $search.engine and $search.phrase to php variables $search.engine and $search.phrase. Once those two variables are set in PHP, I've got the rest.

Two Questions,

How do I execute a PHP script from within Smarty?

How do I pass a variable from Smarty to PHP?

Any help on this would be appreciated!
__________________
Jeremy Freeman
EZWatch Store
X-Cart v4.1.5
Reply With Quote
  #2  
Old 05-02-2005, 04:47 PM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

Code:
{* smarty *} {php} echo "I'm in PHP"; {/php} {* back to smarty *}

As for getting Smarty object variables you can easily see they are accessible with following template code:

Code:
{php}func_print_r($this->_tpl_vars);{/php}
http://cart-lab.blogspot.com/2005/03/convient-way-to-debug-template.html

..And if your not doing the php inside of a .tpl, simply use $Smarty instead of $this.
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #3  
Old 05-03-2005, 11:10 AM
 
Jeremy.Freeman Jeremy.Freeman is offline
 

Advanced Member
  
Join Date: Mar 2005
Posts: 79
 

Default

Thank you for your previous answer, I have one more question..

I have found the values I need in PHP.. how do I reference them? Ive come up with:

Code:
[_userinfo] => Array ( [extra] => a:2:{s:17:"additional_fields";a:2:{i:0;a:4:{s:7:"fieldid";s:1:"1";s:7:"section";s:1:"A";s:5:"value";s:7:"ezwatch";s:5:"title";s:37:"What search term was used to find us?";}i:1;a:4:{s:7:"fieldid";s:1:"2";s:7:"section";s:1:"A";s:5:"value";s:5:"Yahoo";s:5:"title";s:31:"What search engine did you use?";}}s:8:"tax_info";a:5:{s:26:"display_taxed_order_totals";s:1:"N";s:31:"display_cart_products_tax_rates";b:0;s:14:"taxed_subtotal";s:7:"1642.00";s:25:"taxed_discounted_subtotal";s:7:"1642.00";s:14:"taxed_shipping";s:5:"84.25";}}

I need to be able to call extra.. How do I go about this in PHP?

Ive tried $_userinfo[extra] but that doesnt seem to do anything..
__________________
Jeremy Freeman
EZWatch Store
X-Cart v4.1.5
Reply With Quote
  #4  
Old 05-03-2005, 11:36 AM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

Try:
Code:
$Smarty->_tpl_vars['_userinfo']['extra']
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #5  
Old 05-03-2005, 11:42 AM
 
Jeremy.Freeman Jeremy.Freeman is offline
 

Advanced Member
  
Join Date: Mar 2005
Posts: 79
 

Default

That sure makes a lot more sense, but unfortunately it doesn't do anything still.. My code is

Code:
{php} echo $Smarty->_tpl_vars['_userinfo']['extra']; {/php}
__________________
Jeremy Freeman
EZWatch Store
X-Cart v4.1.5
Reply With Quote
  #6  
Old 05-03-2005, 11:59 AM
 
Jeremy.Freeman Jeremy.Freeman is offline
 

Advanced Member
  
Join Date: Mar 2005
Posts: 79
 

Default

Nevermind, I changed $Smarty to $this (im in {php}).. Thanks a ton!
__________________
Jeremy Freeman
EZWatch Store
X-Cart v4.1.5
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 06:41 PM.

   

 
X-Cart forums © 2001-2020