Example #1
0
 /**
  * notifyBuyers
  *
  * @param array $order_ids
  * @param integer $status
  * @return boolean
  */
 public function notifyBuyers($order_ids, $status)
 {
     $output = true;
     if (!is_array($order_ids)) {
         $order_ids = array($order_ids);
     }
     //Параметры сниппета Shopkeeper3
     $snippet_properties = array();
     $response = $this->modx->runProcessor('getsnippetproperties', array(), array('processors_path' => $this->modx->getOption('core_path') . 'components/shopkeeper3/processors/mgr/'));
     if (!$response->isError()) {
         $snippet_properties = $response->getObject();
     }
     require_once $this->modx->getOption('core_path') . "components/shopkeeper3/model/shopkeeper.class.php";
     $shopCart = new Shopkeeper($this->modx, $snippet_properties);
     $config = $shopCart->getConfig(array('statuses'));
     foreach ($order_ids as $order_id) {
         //Данные заказа
         $response = $this->modx->runProcessor('getorder', array('order_id' => $order_id), array('processors_path' => $this->modx->getOption('core_path') . 'components/shopkeeper3/processors/mgr/'));
         if ($response->isError()) {
             $output = false;
             break;
         } else {
             $order_data = $response->getObject();
             if (empty($order_data['email'])) {
                 continue;
             }
             //Параметры статуса
             $status_data = array();
             foreach ($config['statuses'] as $st) {
                 if ($st['id'] == $status) {
                     $status_data = $st;
                     break;
                 }
             }
             if (empty($status_data) || empty($status_data['tpl'])) {
                 continue;
             }
             $mainChunk = $shopCart->getChunk($status_data['tpl']);
             //Данные товаров заказа
             $purchasesArray = $order_data['purchases'];
             foreach ($purchasesArray as &$purchase) {
                 if (!empty($purchase['options'])) {
                     $p_options = $shopCart->getPurchasesOptionsData($purchase['options']);
                     $purchase = array_merge($purchase, $p_options);
                     unset($purchase['options']);
                 }
             }
             //Формируем письмо
             $orderOutputData = $shopCart->getOrderData($order_id);
             $chunkArr = array('orderID' => $order_data['id'], 'orderDate' => $order_data['date'], 'statusName' => $status_data['label'], 'orderCurrency' => $shopCart->config['currency'], 'orderOutputData' => $orderOutputData);
             unset($order_data['contacts'], $order_data['purchases']);
             $chunkArr = array_merge($order_data, $chunkArr);
             $mail_body = $shopCart->parseTpl($mainChunk, $chunkArr, $status_data['tpl']);
             $subject = $this->modx->lexicon('shk3.order_change_status');
             $this->SHKsendMail($subject, $mail_body, $order_data['email']);
         }
     }
     return $output;
 }
Example #2
0
 function sendOrderToManager(&$fields)
 {
     global $modx, $shkconf;
     if (!class_exists('Shopkeeper')) {
         require_once MODX_BASE_PATH . "assets/snippets/shopkeeper/class.shopkeeper.php";
     }
     $shopCart = new Shopkeeper($modx, $shkconf);
     $shopCart->sendOrderToManager($fields);
     return true;
 }
Example #3
0
 public function getProductsData($page, $productsIds = array())
 {
     $productsData = array();
     if (in_array($page, array("category", "product"))) {
         if (empty($productsIds)) {
             return array();
         }
         $criteria = $this->modx->newQuery('ShopContent');
         $criteria->where(array('id:IN' => $productsIds));
         $items = $this->modx->getIterator('ShopContent', $criteria);
         foreach ($items as $item) {
             $productsData[] = array("article" => $item->id, "name" => $item->pagetitle, "imageUrl" => "http://" . $_SERVER['SERVER_NAME'] . (defined('MODX_ASSETS_URL') ? MODX_ASSETS_URL : '/assets') . '/' . $item->image, "quantity" => 1, "amount" => $item->price);
         }
         return $productsData;
     }
     if (in_array($page, array("cart"))) {
         //Определяем параметры сниппета Shopkeeper
         $sys_property_sets = $this->modx->getOption('shk3.property_sets', $this->modx->config, 'default');
         $sys_property_sets = explode(',', $sys_property_sets);
         $propertySetName = trim(current($sys_property_sets));
         $snippet = $this->modx->getObject('modSnippet', array('name' => 'Shopkeeper3'));
         $properties = $snippet->getProperties();
         if ($propertySetName != 'default' && $this->modx->getCount('modPropertySet', array('name' => $propertySetName)) > 0) {
             $propSet = $this->modx->getObject('modPropertySet', array('name' => $propertySetName));
             $propSetProperties = $propSet->getProperties();
             if (is_array($propSetProperties)) {
                 $properties = array_merge($properties, $propSetProperties);
             }
         }
         $lang = $this->modx->getOption('lang', $properties, 'ru');
         $this->modx->getService('lexicon', 'modLexicon');
         $this->modx->lexicon->load($lang . ':shopkeeper3:default');
         if (!empty($_SESSION['shk_order'])) {
             require_once SHOPKEEPER_PATH . "model/shopkeeper.class.php";
             $shopCart = new Shopkeeper($this->modx, $properties);
             $purchasesData = $shopCart->getProductsData(true);
             $_tmp_purchasesData = array();
             foreach ($shopCart->data as $p_data) {
                 $_tmp_purchasesData[$p_data['id']] = array("price" => $p_data['price'], "quantity" => $p_data['count']);
             }
             foreach ($purchasesData as $cartItem) {
                 $productsData[] = array("article" => $cartItem['id'], "name" => $cartItem['pagetitle'], "imageUrl" => "http://" . $_SERVER['SERVER_NAME'] . (defined('MODX_ASSETS_URL') ? MODX_ASSETS_URL : '/assets') . '/' . $cartItem['image'], "quantity" => isset($_tmp_purchasesData[$cartItem['id']]) ? $_tmp_purchasesData[$cartItem['id']]["quantity"] : 1, "amount" => (isset($_tmp_purchasesData[$cartItem['id']]) ? $_tmp_purchasesData[$cartItem['id']]["quantity"] : 1) * $cartItem['price']);
             }
         }
         return $productsData;
     }
 }
Example #4
0
 function shk_currency_calc($properties, $base_price, $currency_id, $rate_ratio = 0)
 {
     $inverse = isset($properties['inverse']) ? $properties['inverse'] : false;
     //обратный перевод цены
     if (!$rate_ratio) {
         if (isset($_SESSION['shk_curr_rate']) && is_numeric($_SESSION['shk_curr_rate']) && !$inverse) {
             $rate_ratio = $_SESSION['shk_curr_rate'];
         } else {
             if (!isset($properties['currency_rate'])) {
                 require_once MODX_CORE_PATH . "components/shopkeeper3/model/shopkeeper.class.php";
                 $config = Shopkeeper::getConfig(array('currency_rate'));
                 $properties['currency_rate'] = $config['currency_rate'];
             }
             $rate_ratio = 1;
             if ($properties['currency_default'] != $currency_id) {
                 $rate_default = 1;
                 $rate = 1;
                 //Определяем курс по умолчанию и новый курс
                 foreach ($properties['currency_rate'] as $rt) {
                     if ($rt['id'] == $properties['currency_default']) {
                         $rate_default = Shopkeeper::cleanNumber($rt['value'], 'float');
                     } else {
                         if ($rt['id'] == $currency_id) {
                             $rate = Shopkeeper::cleanNumber($rt['value'], 'float');
                         }
                     }
                 }
                 if (!$inverse) {
                     $rate_ratio = $rate_default / $rate;
                     $_SESSION['shk_curr_rate'] = $rate_ratio;
                 } else {
                     $rate_ratio = $rate / $rate_default;
                 }
             }
         }
     }
     //Считаем цену по курсу
     if ($rate_ratio) {
         $price = $base_price * $rate_ratio;
         $price = round($price, ceil($price) == $price ? 0 : 2);
         return $price;
     } else {
         return $base_price;
     }
 }
Example #5
0
 public function updateShopkeeper3Order($order_id)
 {
     if (empty($order_id)) {
         return false;
     }
     if (!empty($_SESSION['shk_order'])) {
         require_once SHOPKEEPER_PATH . "model/shopkeeper.class.php";
         $shopCart = new Shopkeeper($this->getModX(), $properties);
         $this->getModX()->addPackage('shopkeeper3', SHOPKEEPER_PATH . 'model/');
         //Доставка
         $delivery = $this->getPayqr()->getDeliveryCasesSelected();
         $delivery_price = isset($delivery->amountFrom) ? $delivery->amountFrom : 0;
         $delivery_name = isset($delivery->name) ? $delivery->name : "";
         //Сохраняем данные заказа
         $insert_data = array('contacts' => $this->getBuyerContacts(), 'options' => '', 'price' => $this->getTotal(), 'currency' => $shopCart->config['currency'], 'date' => strftime('%Y-%m-%d %H:%M:%S'), 'sentdate' => strftime('%Y-%m-%d %H:%M:%S'), 'note' => '', 'email' => $emailField, 'delivery' => $delivery_name, 'delivery_price' => $delivery_price, 'payment' => 'PayQR', 'tracking_num' => '', 'status' => '1');
         if ($userId) {
             $insert_data['userid'] = $userId;
         }
         //производим обновление товара
         $result = $this->modxUpdate($insert_data, $this->getModX()->getOption('table_prefix') . "shopkeeper3_orders", "id='" . $order_id . "'");
         if ($result) {
             $purchasesData = $shopCart->getProductsData(true);
             //удаляем все старые товары из заказа
             $this->getModX()->query("DELETE FROM " . $this->getModX()->getOption('table_prefix') . "shopkeeper3_purchases WHERE order_id = " . $order_id);
             //
             foreach ($shopCart->data as $key => $p_data) {
                 $options = !empty($p_data['options']) ? json_encode($p_data['options']) : '';
                 $fields_data = !empty($purchasesData[$key]) ? $purchasesData[$key] : array();
                 $fields_data['url'] = !empty($p_data['url']) ? $p_data['url'] : '';
                 unset($fields_data['id']);
                 $fields_data_str = json_encode($fields_data);
                 $insert_data = array('p_id' => $p_data['id'], 'order_id' => $order_id, 'name' => $p_data['name'], 'price' => $p_data['price'], 'count' => $p_data['count'], 'class_name' => 'ShopContent', 'package_name' => 'shop', 'data' => $fields_data_str, 'options' => $options);
                 $purchase = $this->getModX()->newObject('shk_purchases');
                 $purchase->fromArray($insert_data);
                 $purchase->save();
             }
         }
         return true;
     } else {
         return null;
     }
 }
Example #6
0
 * Сниппет выводит данные из конфигурации Shopkeeper
 *
 */
$output = array();
$get = explode(',', $modx->getOption('get', $scriptProperties, ''));
$post_name = explode(',', $modx->getOption('post_name', $scriptProperties, $get));
$get = array_map('trim', $get);
$post_name = array_map('trim', $post_name);
$tpl = $modx->getOption('tpl', $scriptProperties, '');
$toPlaceholders = $modx->getOption('toPlaceholders', $scriptProperties, false);
$pl_prefix = $modx->getOption('pl_prefix', $scriptProperties, 'shkopt_');
if (empty($get)) {
    return '';
}
if (class_exists('Shopkeeper')) {
    $config = Shopkeeper::getConfig($get);
    //echo '<pre>' . print_r( $config, true ) . '</pre>';
    if (!empty($config)) {
        foreach ($get as $index => $opt_name) {
            if (!empty($config[$opt_name])) {
                $output[$opt_name] = '';
                foreach ($config[$opt_name] as $key => $conf) {
                    if (empty($conf['value'])) {
                        $conf['value'] = $conf['label'];
                    }
                    $conf['selected'] = isset($post_name[$index]) && isset($_POST[$post_name[$index]]) && $_POST[$post_name[$index]] == $conf['value'] ? 'selected="selected"' : '';
                    $output[$opt_name] .= $modx->getChunk($tpl, $conf) . PHP_EOL . "\t";
                }
            }
        }
    }
Example #7
0
 /**
  *
  *
  */
 function __construct(&$modx)
 {
     parent::__construct($modx);
 }
Example #8
0
 /**
  * getTotal
  *
  */
 public function getTotal()
 {
     self::$price_total = 0;
     self::$items_total = 0;
     self::$items_unique_total = 0;
     if (!empty($this->data)) {
         foreach ($this->data as $parchase) {
             self::$price_total += $parchase['price'] * $parchase['count'];
             self::$items_total += $parchase['count'];
             if (!empty($parchase['options'])) {
                 //доп параметры товара
                 foreach ($parchase['options'] as $opts) {
                     if (!empty($opts[1])) {
                         self::$price_total += $opts[1] * $parchase['count'];
                     }
                 }
             }
         }
         self::$items_unique_total = count($this->data);
     }
     //Добавляем цену доставки
     if (!empty($this->delivery) && !empty($this->delivery['price'])) {
         self::$price_total += $this->delivery['price'];
     }
     //OnSHKcalcTotalPrice
     $new_price = $this->getFromEvent('OnSHKcalcTotalPrice', array('price_total' => self::$price_total), 'float');
     if ($new_price !== false) {
         self::$price_total = $new_price;
     }
     return self::$price_total;
 }
Example #9
0
$propertySetName = trim(current($sys_property_sets));
$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);
    }
}
$lang = $modx->getOption('lang', $properties, 'ru');
$modx->getService('lexicon', 'modLexicon');
$modx->lexicon->load($lang . ':shopkeeper3:default');
if (!empty($_SESSION['shk_order'])) {
    require_once SHOPKEEPER_PATH . "model/shopkeeper.class.php";
    $shopCart = new Shopkeeper($modx, $properties);
    $modx->addPackage('shopkeeper3', SHOPKEEPER_PATH . 'model/');
    //shopkeeper settings
    $contacts_fields = array();
    $response = $modx->runProcessor('getsettings', array('settings' => array('contacts_fields')), array('processors_path' => $modx->getOption('core_path') . 'components/shopkeeper3/processors/mgr/'));
    if ($response->isError()) {
        echo $response->getMessage();
    }
    if ($result = $response->getResponse()) {
        $temp_arr = !empty($result['object']['contacts_fields']) ? $result['object']['contacts_fields'] : array();
        if (!empty($temp_arr)) {
            foreach ($temp_arr as $opt) {
                $contacts_fields[$opt['name']] = $opt;
            }
        }
    }
Example #10
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);
 *
 * Shopkeeper plugin group goods in cart
 * 
 * System event: OnSHKcartLoad
 * 
 * settings: &groupWrapTpl=group wrapper;string;cart-group-tpl
 */
if (!defined('MODX_BASE_PATH')) {
    die('What are you doing? Get out of here!');
}
$e =& $modx->Event;
$groupWrapTpl = isset($groupWrapTpl) ? $groupWrapTpl : '';
if ($e->name == 'OnSHKcartLoad' && $GLOBALS['shkconf']['cartType'] == "full" && $groupWrapTpl) {
    require_once MODX_BASE_PATH . "assets/snippets/shopkeeper/classes/class.shopkeeper.php";
    $shkconf = $GLOBALS['shkconf'];
    $shk = new Shopkeeper($modx, $shkconf);
    $output = "";
    $purchasesByGroup = array();
    $additByGroup = array();
    $thisPage = $modx->documentIdentifier;
    $this_page_url = is_int($thisPage) ? $modx->makeUrl($thisPage, '', '', 'full') : null;
    $purchases = unserialize($_SESSION['purchases']);
    $addit_params = !empty($_SESSION['addit_params']) ? unserialize($_SESSION['addit_params']) : array();
    $inner = '';
    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();
 /**
  *
  *
  */
 function __construct(&$modx, $config)
 {
     parent::__construct($modx);
     $this->config = array_merge(array("lang" => "russian-UTF-8", "oneLevelMenu" => false, "id_prefix" => ""), $config);
 }
Example #13
0
 * @version 	   3.x
 * @license 	   http://www.gnu.org/copyleft/gpl.html GNU Public License (GPL)
 * @internal	   @properties
 * @internal	   @modx_category Shop
 */
if (isset($hideOn) && preg_match('/(^|\\s|,)' . $modx->resource->get('id') . '(,|$)/', $hideOn)) {
    return '';
}
$modx->placeholders['SHK_callCount'] = isset($modx->placeholders['SHK_callCount']) ? $modx->placeholders['SHK_callCount'] + 1 : 1;
$SHK_callCount = $modx->placeholders['SHK_callCount'];
if (!defined('SHOPKEEPER_URL')) {
    define('SHOPKEEPER_URL', $modx->getOption('assets_url') . "components/shopkeeper3/");
}
$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);
Example #14
0
 $shkconf['currency'] = isset($request['currency']) ? $request['currency'] : '';
 $shkconf['charset'] = $charset;
 if (empty($defaultProp['tplPath'])) {
     $defaultProp['tplPath'] = "assets/snippets/shopkeeper/chunks/" . substr($shkconf['lang'], 0, 2) . "/";
 }
 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);
Example #15
0
 /**
  * savePurchases
  *
  */
 public function savePurchases($order_id, $purchases_data)
 {
     $p_ids = array();
     $del_ids = array();
     $query = $this->modx->newQuery('shk_purchases');
     $query->where(array('order_id' => $order_id));
     $purchases = $this->modx->getIterator('shk_purchases', $query);
     $className = '';
     $packageName = '';
     if ($purchases) {
         foreach ($purchases as $purchase) {
             $index = -1;
             foreach ($purchases_data as $k => $temp_arr) {
                 if (!empty($temp_arr['id']) && $temp_arr['id'] == $purchase->id) {
                     $index = $k;
                     break;
                 }
             }
             if ($index > -1) {
                 if (!empty($purchases_data[$index]['options'])) {
                     $options = array();
                     foreach ($purchases_data[$index]['options'] as $k => $v) {
                         if (!empty($v[0])) {
                             $options[$k] = $v;
                         }
                     }
                     $purchases_data[$index]['options'] = json_encode($options);
                 }
                 $purchase->fromArray($purchases_data[$index]);
                 $purchase->save();
             } else {
                 array_push($del_ids, $purchase->id);
             }
             if (!empty($purchase->class_name) && !empty($purchase->package_name)) {
                 $className = $purchase->class_name;
                 $packageName = $purchase->package_name;
             }
         }
         //print_r($purchases_data);
         //Сохраняем новые товары
         if ($purchases_data) {
             //Параметры сниппета Shopkeeper3
             $snippet_properties = array();
             $response = $this->modx->runProcessor('getsnippetproperties', array(), array('processors_path' => $this->modx->getOption('core_path') . 'components/shopkeeper3/processors/mgr/'));
             if (!$response->isError()) {
                 $snippet_properties = $response->getObject();
             }
             require_once $this->modx->getOption('core_path') . "components/shopkeeper3/model/shopkeeper.class.php";
             $shopCart = new Shopkeeper($this->modx, $snippet_properties);
             $shopCart->addPackage($packageName);
             foreach ($purchases_data as $k => $temp_arr) {
                 if (empty($temp_arr['id'])) {
                     $new_p = array('p_id' => !empty($temp_arr['p_id']) ? $temp_arr['p_id'] : 0, 'order_id' => $order_id, 'name' => $temp_arr['name'], 'count' => !empty($temp_arr['count']) ? $temp_arr['count'] : 1, 'price' => !empty($temp_arr['price']) ? $temp_arr['price'] : '', 'options' => !empty($temp_arr['options']) ? $temp_arr['options'] : '', 'class_name' => $className, 'package_name' => $packageName);
                     if (is_array($new_p['options'])) {
                         $new_p['options'] = json_encode($new_p['options']);
                     }
                     //Если нет названия или цены
                     if (!empty($new_p['p_id']) && empty($new_p['name']) || empty($new_p['price'])) {
                         $shopCart->getPurchaseFromDB($new_p['p_id'], $className);
                         if (is_object($shopCart->purchase)) {
                             if (empty($new_p['name'])) {
                                 $new_p['name'] = $shopCart->purchase->get($shopCart->config['fieldName']);
                             }
                             if (!isset($new_p['price']) || $new_p['price'] == '') {
                                 $new_p['price'] = $shopCart->getProductPrice();
                             }
                             $fields_data = array('url' => $shopCart->getPurchaseUrl());
                             $fields_data_str = json_encode($fields_data);
                             $new_p['data'] = $fields_data_str;
                         } else {
                             $new_p['price'] = 0;
                         }
                     }
                     $purchase = $this->modx->newObject('shk_purchases');
                     $purchase->fromArray($new_p);
                     $purchase->save();
                 }
             }
         }
         //Удаляем товары
         if (count($del_ids) > 0) {
             $affected = $this->modx->removeCollection('shk_purchases', array("order_id" => $order_id, "id:IN" => $del_ids));
         }
         return true;
     } else {
         return false;
     }
 }