X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Passing Smarty variable to PHP (https://forum.x-cart.com/showthread.php?t=13768)

Jeremy.Freeman 05-02-2005 02:49 PM

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!

B00MER 05-02-2005 04:47 PM

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}
:arrow: 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.

Jeremy.Freeman 05-03-2005 11:10 AM

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

B00MER 05-03-2005 11:36 AM

Try:
Code:

$Smarty->_tpl_vars['_userinfo']['extra']

Jeremy.Freeman 05-03-2005 11:42 AM

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 05-03-2005 11:59 AM

Nevermind, I changed $Smarty to $this (im in {php}).. Thanks a ton!


All times are GMT -8. The time now is 11:00 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.