Pass Smarty Variable To Php In Cs-Cart 4.2.4

In cs-cart version 3.x the following worked fine:

In tpl file

[size=4] {assign var=“SH_ID” value=‘whatever’}[/size]

and in PHP file

[size=3] $SH_ID = $this->get_template_vars(‘SH_ID’);[/size]

[size=3]But in 4.2.4 this doesn’t work. [/size][size=3]Any hint on how to pass a smarty variable to PHP in cs-cart 4.2.4[/size]



I know that i had a same issue regarding smarty code for IP adres.

example IP adres smarty Code:

Php code:


In smarty code


Maybe this should help you further and hope you get it work.

I'm not sure about this codes, but give it a try

{assign var="SH_ID" value=$smarty.whatever} or
{assign var="SH_ID" value=$smarty.request.whatever}


That didn't work, but I found a better solution for my modification. I modified the cs-cart php code in fn.cart.php to call my arrivalDate subroutine that I placed in app/addons/my_changes/func.php.

foreach ($group['shippings'] as $shipping_id => $shipping) {

$arrive = arriveDate($shipping_id); //call function and pass in $shipping_id

// Assign smarty variables to PHP variable
Registry::get('view')->assign('arrive', $arrive);


now I can show the newly calculated arrival date in shipping_rates.tpl

By the way, my modification shows the customer (during step 3 of checkout) the estimated arrival date based on production time of product being purchased (calculated in [color=#282828][font=arial, verdana, tahoma, sans-serif][size=3]productionDate subroutine [/size][/font][/color][size=3]I placed in app/addons/my_changes/func.php), [/size][size=4]holidays, and available shipping methods. This is important because our products each have unique production time.[/size]

In Step 3 of checkout the shipping radio selection looks like:

[size=3][color=#333333][font=Tahoma, Geneva, sans-serif]USPS Priority Mail (Not recommended if you need by a specific date) - $8.29[/font][/color][/size]

[color=#333333][font=Tahoma, Geneva, sans-serif][size=3]FedEx Ground - $12.26 [/size][/font][/color][color=#ff0000][size=3](Click to view ground arrival dates based on zipcode)[/size][/color]

[color=#333333][font=Tahoma, Geneva, sans-serif][size=3]FedEx 2nd day (by end of day) - $44.28 [color=red](estimated to arrive on 01/07/2015)[/color][/size][/font][/color]

[color=#333333][font=Tahoma, Geneva, sans-serif][size=3]FedEx Priority Overnight (Morning) - $76.10 [color=red](estimated to arrive on 01/06/2015)[/color][/size][/font][/color]