require_once MODX_CORE_PATH . 'model/modx/modx.class.php'; $modx = new modX(); $modx->initialize('web'); $modx->invokeEvent("OnLoadWebDocument"); define('SHOPKEEPER_PATH', MODX_BASE_PATH . "core/components/shopkeeper3/"); define('SHOPKEEPER_URL', MODX_BASE_URL . "core/components/shopkeeper3/"); $manager_language = $modx->config['manager_language']; $charset = $modx->config['modx_charset']; header("Content-Type: text/html; charset={$charset}"); require_once SHOPKEEPER_PATH . "model/shopkeeper.class.php"; //Определяем параметры сниппета Shopkeeper $sys_property_sets = $modx->getOption('shk3.property_sets', null, 'default'); $sys_property_sets = explode(',', $sys_property_sets); $sys_property_sets = array_map('trim', $sys_property_sets); $propertySerNum = isset($_POST['psn']) && is_numeric($_POST['psn']) ? intval($_POST['psn']) : 1; $propertySetName = isset($sys_property_sets[$propertySerNum - 1]) ? $sys_property_sets[$propertySerNum - 1] : $sys_property_sets[0]; $snippet = $modx->getObject('modSnippet', array('name' => 'Shopkeeper3')); $properties = $snippet->getProperties(); if ($propertySetName != 'default' && $modx->getCount('modPropertySet', array('name' => $propertySetName)) > 0) { $propSet = $modx->getObject('modPropertySet', array('name' => $propertySetName)); $propSetProperties = $propSet->getProperties(); if (is_array($propSetProperties)) { $properties = array_merge($properties, $propSetProperties); } } $shopCart = new Shopkeeper($modx, $properties); $shopCart->config['charset'] = $charset; $cart_html = $shopCart->getCartContent(); $cart_html = $shopCart->stripModxTags($cart_html); $output = array('price_total' => Shopkeeper::$price_total, 'items_total' => Shopkeeper::$items_total, 'items_unique_total' => Shopkeeper::$items_unique_total, 'delivery_price' => !empty($shopCart->delivery['price']) ? $shopCart->delivery['price'] : 0, 'delivery_name' => !empty($shopCart->delivery['label']) ? $shopCart->delivery['label'] : '', 'ids' => $shopCart->getProdIds(), 'html' => $cart_html); echo json_encode($output);
$output = ''; require_once $modx->getOption('core_path') . "components/shopkeeper3/model/shopkeeper.class.php"; $shopCart = new Shopkeeper($modx, $scriptProperties); if ($SHK_callCount === 1) { if (!empty($scriptProperties['style'])) { $modx->regClientCSS(SHOPKEEPER_URL . "web/css/" . $modx->getOption('style', $scriptProperties, 'default') . "/style.css"); } if (!$modx->getOption('noJavaScript', $scriptProperties, false)) { if (!$modx->getOption('noJQuery', $scriptProperties, false)) { $modx->regClientStartupScript(SHOPKEEPER_URL . "web/js/jquery-1.11.1.min.js"); } $modx->regClientStartupScript(SHOPKEEPER_URL . "web/js/lang/" . $modx->getOption('lang', $scriptProperties, 'ru') . ".js?v=" . $shopCart->getVersion()); $modx->regClientStartupScript(SHOPKEEPER_URL . "web/js/shopkeeper.js?v=" . $shopCart->getVersion()); $shk_opts = array('prodCont' => $modx->getOption('prodCont', $scriptProperties, 'div.shk-item'), 'site_base_url' => $modx->config['base_url'], 'counterField' => $modx->getOption('counterField', $scriptProperties, false), 'counterFieldCart' => $modx->getOption('counterFieldCart', $scriptProperties, true), 'changePrice' => $modx->getOption('changePrice', $scriptProperties, true), 'flyToCart' => $modx->getOption('flyToCart', $scriptProperties, 'helper'), 'noLoader' => $modx->getOption('noLoader', $scriptProperties, false), 'allowFloatCount' => $modx->getOption('allowFloatCount', $scriptProperties, false), 'animCart' => $modx->getOption('animCart', $scriptProperties, true), 'goToOrderFormPage' => $modx->getOption('goToOrderFormPage', $scriptProperties, false), 'orderFormPageUrl' => $modx->makeUrl($modx->getOption('orderFormPageId', $scriptProperties, 1), '', '', 'abs'), 'debug' => $modx->getOption('debug', $scriptProperties, false)); if (defined('JSON_UNESCAPED_SLASHES') && defined('JSON_FORCE_OBJECT')) { $options_obj_str = json_encode($shk_opts, JSON_FORCE_OBJECT | JSON_UNESCAPED_SLASHES); } else { $options_obj_str = json_encode($shk_opts); } $delivery_price = !empty($shopCart->delivery['price']) ? $shopCart->delivery['price'] : 0; $delivery_name = !empty($shopCart->delivery['label']) ? $shopCart->delivery['label'] : 0; //create script $headHtml = "\t<script type=\"text/javascript\">"; $headHtml .= "\n SHK.data = {price_total:" . Shopkeeper::$price_total . ",items_total:" . Shopkeeper::$items_total . ",items_unique_total:" . Shopkeeper::$items_unique_total . ",delivery_price:{$delivery_price},delivery_name:'{$delivery_name}',ids:[" . $shopCart->getProdIds('string') . "]};\n jQuery(document).bind( 'ready', function(){\n SHK.init( " . $options_obj_str . " );\n });" . PHP_EOL; $headHtml .= "\t</script>" . PHP_EOL; $modx->regClientStartupHTMLBlock($headHtml); } } //вывод корзины $output .= $shopCart->getCartContent(); return $output;