first commit
This commit is contained in:
47
class/smarty_plugins/function.get_infopanel.php
Normal file
47
class/smarty_plugins/function.get_infopanel.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* Type: function
|
||||
* Name: get_slider
|
||||
* Purpose: get a slider of known name or id
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
|
||||
use KupShop\ContentBundle\Util\InfoPanelLoader;
|
||||
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
* @param Smarty $smarty
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function smarty_function_get_infopanel($params, &$smarty)
|
||||
{
|
||||
$assign = null;
|
||||
$ret = false;
|
||||
extract($params);
|
||||
|
||||
$infoPanelLoader = ServiceContainer::getService(InfoPanelLoader::class);
|
||||
$infoPanel = $infoPanelLoader->loadInfoPanel($type ?? null);
|
||||
|
||||
if (str_contains($infoPanel['body'] ?? '', '{DOPRAVA_ZDARMA_OD}')) {
|
||||
$currencyContext = ServiceContainer::getService(CurrencyContext::class);
|
||||
$smarty->loadPlugin('Smarty_function_get_stats');
|
||||
$freeDelivery = smarty_function_get_stats(['type' => 'free_delivery'], $smarty);
|
||||
$infoPanel['body'] = str_replace('{DOPRAVA_ZDARMA_OD}', "{$freeDelivery->asInteger()} {$currencyContext->getActive()->getSymbol()}", $infoPanel['body']);
|
||||
}
|
||||
|
||||
if (!empty($infoPanel)) {
|
||||
$ret = $infoPanel;
|
||||
$ret['text'] = $infoPanel['body'];
|
||||
}
|
||||
|
||||
if (!empty($assign)) {
|
||||
$smarty->assign($assign, $ret);
|
||||
} else {
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user