<?php

/*
 * Smarty plugin
 * -------------------------------------------------------------
 * Type:     function
 * Name:     eval
 * Purpose:  evaluate a template variable as a template
 * -------------------------------------------------------------
 */

function smarty_function_insert_cart_info($params, &$smarty)
{
    global $cfg;

    require_once $cfg['Path']['shared_version'].'web/block.cartInfo.php';

    $default = [
        'template' => 'block.cartInfo.tpl',
        'cartInfo' => block_cartInfo(),
    ];

    $params = array_merge($default, $params);

    if (!empty($params['return'])) {
        $smarty->assign($params['return'], $params);

        return;
    }

    if (!empty($params['assign'])) {
        $smarty->assign($params['assign'], $params);
    }

    $_smarty_tpl_vars = $smarty->tpl_vars;

    echo $smarty->_subTemplateRender($params['template'], $smarty->cache_id, $smarty->compile_id, 0, null, $params, 0, false);

    $smarty->tpl_vars = $_smarty_tpl_vars;
}
