Can't Access {$Cart_Products} From Select_Shipping Hook

Hi,

I have a problem with accessing cart_products variable through select_shipping hook.

I can see all available variables on checkout page via debuger but when I add

{$cart_products | @print_r}

in design/themes/responsive/templates/addons/my_changes/hooks/checkout/select_shipping.post.tpl I get an error.

Is there any easy way to print all avaialable smarty variables?

Best regards,

Jacek

You can use

{$cart.products|fn_print_r}

Hope it contains all necessary information

Thank you, it works!

I have another problem, I have a function defined in app/addons/my_changes/func.php and I want to call it from smarty template and assign it's return value to a smarty variable. I'm looking at the docs and can't find any examples. Thank you in advance!

fn_my_changes_bla_bla_bla($cart.products) {
    // Logic
   return $value;
}

Please use

{$data = $cart.products|fn_my_changes_bla_bla_bla}

$data variable will contain response returned by custom function

And if you don't want $data displayed but want to use it as data, then use the 'assign' tag with var="data" value=....

And if you don't want $data displayed but want to use it as data, then use the 'assign' tag with var="data" value=....

Actually, the mentioned code will not output any data

Please use

{$data = $cart.products|fn_my_changes_bla_bla_bla}

$data variable will contain response returned by custom function

Thank you eComLabs, it works! I have another problem: Now I can display {$data} on checkout page. I've added estimated_delivery_date column to cscart_orders and I want to save it to db when customer submits the order.

I've tried adding following code in select_shipping.post.tpl but it doesn't work.


and


Thank you very much once again!

Sorry for asking so many questions, I'm new to addon developement and

I suggest you to use pre checkout hook. If this data is received, just add it to the cart array. E.g.

if (!empty($_REQUEST['estimated_delivery_date'])) {
    $_SESSION['cart']['estimated_delivery_date'] = $_REQUEST['estimated_delivery_date'];
}

(!) Not tested