if ($purchases && count($purchases)) {
        foreach ($purchases as $key => $purchase) {
            $purchasesByGroup[$purchase['tv_add']['shk_group']][] = $purchase;
            $additByGroup[$purchase['tv_add']['shk_group']][] = $addit_params[$key];
        }
        $purchases = array();
        $addit_params = array();
        $num = 0;
        foreach ($purchasesByGroup as $key => $group_temp) {
            $group = array();
            foreach ($group_temp as $pkey => $purchase) {
                $purchases[] = $purchase;
                $addit_params[] = $additByGroup[$key][$pkey];
                $group[$num] = $purchase;
                $num++;
            }
            $innerGroup = $shk->getStuffList($group, $additByGroup[$key], 'table', false, $this_page_url);
            $totalGroup = $shk->getTotal($group_temp, $additByGroup[$key]);
            $params['price_total'] = $totalGroup[1];
            $params['total_items'] = $totalGroup[0];
            $params['group'] = $innerGroup;
            $params['group_name'] = $key;
            $innerGroup = $modx->parseChunk($groupWrapTpl, $params, '[+', '+]');
            $inner .= $innerGroup;
        }
        $_SESSION['purchases'] = serialize($purchases);
        $_SESSION['addit_params'] = serialize($addit_params);
    }
    $e->output($inner);
}
//
示例#2
0
    if ($shkconf['cartHelperTpl']) {
        $helperChunk = preg_split("/[\r\n]+/", trim($shopCart->fetchTpl($shkconf['cartHelperTpl'])));
        $helperStr = '';
        for ($i = 0; $i < count($helperChunk); $i++) {
            $plus = $i == 0 ? '' : '+';
            $helperStr .= "{$plus}'" . trim($helperChunk[$i]) . "'\n";
        }
        $jsSrc .= ",\n\t shkHelper: {$helperStr}";
    }
    $jsSrc .= "\n\t};\r\n      jQuery(document).ready(function(){\r\n        jQuery(shkOptions.stuffCont).shopkeeper();\r\n      });";
    $jsSrc .= "\n\t//-->\n\t</script>";
    $jsSrc .= "\r\n    <script src=\"" . SHOPKEEPER_URL . "lang/" . $shkconf['lang'] . ".js\" type=\"text/javascript\"></script>\r\n    <script src=\"" . SHOPKEEPER_URL . "js/jquery.livequery.js\" type=\"text/javascript\"></script>\r\n    <script src=\"" . SHOPKEEPER_URL . "js/shopkeeper.js\" type=\"text/javascript\"></script>\r\n  ";
    if ($shkconf['debug']) {
        $jsSrc .= "\r\n    <script src=\"" . SHOPKEEPER_URL . "js/log4javascript.js\" type=\"text/javascript\"></script>\r\n    <script src=\"" . SHOPKEEPER_URL . "js/shkdebug.js\" type=\"text/javascript\"></script>";
    }
    $modx->regClientScript($jsSrc);
}
$thisPage = $modx->documentIdentifier;
$orderFormPageUrl = $modx->makeUrl($shkconf['orderFormPage'], '', '', 'full');
$evtOut = $modx->invokeEvent('OnSHKFrontendInit');
if (is_array($evtOut)) {
    $output .= implode('', $evtOut);
}
unset($evtOut);
//
$purchases = !empty($_SESSION['purchases']) ? unserialize($_SESSION['purchases']) : array();
$addit_params = !empty($_SESSION['addit_params']) ? unserialize($_SESSION['addit_params']) : array();
list($totalItems, $totalPrice) = $shopCart->getTotal($purchases, $addit_params);
$modx->setPlaceholder('totalItems', $totalItems);
$modx->setPlaceholder('totalPrice', $totalPrice);
$output .= $shopCart->getCartContent($orderFormPageUrl, $thisPage, $langTxt);