<?php

function smarty_function_get_on_the_way($params, &$smarty)
{
    if (empty($params['id_product'])) {
        throw new InvalidArgumentException('Missing parameter \'id_product\'');
    }

    $return = \KupShop\KupShopBundle\Util\Compat\ServiceContainer::getService(\KupShop\CatalogBundle\Util\Product\ProductGetOnTheWay::class)->getOnTheWay($params['id_product']);

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