示例#1
0
 public function outputArray(array $array, $count = false)
 {
     $response = parent::outputArray($array, $count);
     $object = $response['object'];
     if ($response['success']) {
         $response['object'] = array("sum" => $response['sum'], "original_sum" => $response['original_sum'], "discount" => $response['discount'], "total" => $response['quantity']);
     } else {
         $response['object'] = array();
     }
     return $response;
 }
示例#2
0
 public function afterIteration(array $list)
 {
     $list = parent::afterIteration($list);
     /*
         [quantity] => Array
     (
         [78] => 10
         [79] => 2
         [80] => 1
         [81] => 1
         [83] => 2
     )
     */
     $processors_path = dirname(dirname(dirname(dirname(__FILE__)))) . '/';
     $products = (array) $this->getProperty('quantity');
     foreach ($list as &$l) {
         $order_product_id = $l['id'];
         if (isset($products[$order_product_id])) {
             $quantity = (int) $products[$order_product_id];
             if ($quantity != $l['quantity']) {
                 $this->modx->error->reset();
                 $properties = array('product_key' => $order_product_id, 'quantity' => $quantity);
                 if (!($response = $this->modx->runProcessor("basket/web/orders/products/update", $properties, array("processors_path" => $processors_path)))) {
                     $error = "Ошибка выполнения запроса";
                     $this->modx->log(xPDO::LOG_LEVEL_ERROR, __CLASS__ . " - {$error}");
                     $this->modx->log(xPDO::LOG_LEVEL_ERROR, print_r($this->getProperties(), true));
                     $this->modx->log(xPDO::LOG_LEVEL_ERROR, print_r($properties, true));
                 } else {
                     if ($response->isError()) {
                         $error = $response->getMessage();
                         $this->modx->log(xPDO::LOG_LEVEL_ERROR, __CLASS__ . " - {$error}");
                         $this->modx->log(xPDO::LOG_LEVEL_ERROR, print_r($this->getProperties(), true));
                         $this->modx->log(xPDO::LOG_LEVEL_ERROR, print_r($response->getResponse(), true));
                     } else {
                         $l['quantity'] = $quantity;
                     }
                 }
             }
         }
     }
     return $list;
 }
示例#3
0
 public function setSelection(xPDOQuery $c)
 {
     $c = parent::setSelection($c);
     $c->select(array("{$this->classKey}.price as order_price", "{$this->classKey}.id as `key`"));
     return $c;
 }