Example #1
0
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);
Example #2
0
$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;
Example #3
0
        $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);
Example #4
0
 }
 if (file_exists("lang/" . $shkconf['lang'] . "-" . str_replace('-', '', $charset) . ".php")) {
     $s_lang = $shkconf['lang'] . "-" . str_replace('-', '', $charset);
 } elseif (file_exists("lang/" . $shkconf['lang'] . ".php")) {
     $s_lang = $shkconf['lang'];
 } else {
     $s_lang = "russian";
 }
 $shkconf['lang'] == $s_lang;
 $thisPage = $_SERVER['HTTP_REFERER'];
 $action = $request['action'];
 $shopCart = new Shopkeeper($modx, array_merge($shkconf, $defaultProp));
 switch ($action) {
     case "fill_cart":
         $shopCart->savePurchaseData($request);
         $output = $shopCart->getCartContent($shkconf['orderFormPage'], $thisPage);
         break;
     case "empty":
         $shopCart->emptySavedData();
         $output = $shopCart->getCartContent($shkconf['orderFormPage'], $thisPage);
         break;
     case "delete":
         $shopCart->delArrayItem($request['index']);
         $output = $shopCart->getCartContent($shkconf['orderFormPage'], $thisPage);
         break;
     case "recount":
         $shopCart->recountDataArray($request['index'], $request['count'], false);
         $output = $shopCart->getCartContent($shkconf['orderFormPage'], $thisPage);
         break;
     case "refresh_cart":
         $output = $shopCart->getCartContent($shkconf['orderFormPage'], $thisPage);