echo "<a href = '/ecommerce/view/{$item->id}'>" . $price->offer->item->name() . "</a>"; } else { echo 'Товар удален'; } break; case '4': $info = explode('|', $status->info); $price = Ecommerce\Item\Offer\Price::get($info[0]); if ($price) { echo "<a href = '/ecommerce/view/{$item->id}'>" . $price->offer->item->name() . "</a> " . ($info[1] > 0 ? '+' . $info[1] : $info[1]); } else { echo 'Товар удален'; } break; case '5': echo Ecommerce\Cart\Status::get($status->info)->name; break; default: echo $status->info; } ?> </td> </tr> <?php } ?> </tbody> </table>
public function cartStatusDetector($event) { $cart = $event['eventObject']; if (!empty($cart->_changedParams['cart_cart_status_id'])) { $cart->date_status = date('Y-m-d H:i:s'); $event = new Ecommerce\Cart\Event(['cart_id' => $cart->id, 'user_id' => \Users\User::$cur->id, 'cart_event_type_id' => 5, 'info' => $cart->cart_status_id]); $event->save(); $prev_status_id = $cart->_changedParams['cart_cart_status_id']; $now_status_id = $cart->cart_status_id; $status = Ecommerce\Cart\Status::getList(['where' => ['id', implode(',', [$prev_status_id, $now_status_id]), 'IN']]); $prefix = isset(App::$cur->ecommerce->config['orderPrefix']) ? $config = App::$cur->ecommerce->config['orderPrefix'] : ''; \App::$cur->users->AddUserActivity($cart->user_id, 3, "Статус вашего заказа номер {$prefix}{$cart->id} изменился с {$status[$prev_status_id]->name} на {$status[$now_status_id]->name}"); if ($cart->cart_status_id == 5) { Inji::$inst->event('ecommerceCartClosed', $cart); } } return $cart; }
<?php return function ($step = NULL, $params = []) { // стандартыне статусы $statuses = [['name' => 'Оформляется', 'type' => 'process', 'code' => 'info'], ['name' => 'Оформлен', 'type' => 'complete', 'code' => 'primary'], ['name' => 'Готовится к откгрузке', 'type' => 'accept', 'code' => 'success'], ['name' => 'Отменен', 'type' => 'cancel', 'code' => 'danger'], ['name' => 'Закрыт', 'type' => 'close', 'code' => 'default'], ['name' => 'Обработан', 'type' => 'read', 'code' => 'muted']]; foreach ($statuses as $status) { $statusObj = new \Ecommerce\Cart\Status($status); $statusObj->save(); } //Стандартные типы событий $types = [['name' => 'Добавление товара'], ['name' => 'Удаление товара'], ['name' => 'Изменение цены'], ['name' => 'Изменение количества'], ['name' => 'Изменение статуса']]; foreach ($types as $type) { $typeObj = new \Ecommerce\Cart\Event\Type($type); $typeObj->save(); } Inji::$inst->listen('modelItemParamsChanged-Ecommerce\\Cart', 'Ecommerce-cartStatusDetector', ['module' => 'Ecommerce', 'method' => 'cartStatusDetector'], true); Inji::$inst->listen('ecommerceCartClosed', 'Ecommerce-cardTrigger', ['module' => 'Ecommerce', 'method' => 'cardTrigger'], true); Inji::$inst->listen('ecommerceCartClosed', 'Ecommerce-bonusTrigger', ['module' => 'Ecommerce', 'method' => 'bonusTrigger'], true); };