/** * 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; }