/**
  * Install handlers
  */
 public static function installHandlers(ActionEvent $event)
 {
     $currency = \Yii::$app->getModule('seo')->analytics['ecYandex']['currency'];
     if (AnalyticsHandler::CURRENCY_MAIN === intval($currency)) {
         static::$currency = CurrencyHelper::getMainCurrency();
     } elseif (AnalyticsHandler::CURRENCY_USER === intval($currency)) {
         static::$currency = CurrencyHelper::getUserCurrency();
     } else {
         static::$currency = CurrencyHelper::findCurrencyByIso($currency);
     }
     $route = implode('/', [$event->action->controller->module->id, $event->action->controller->id, $event->action->id]);
     Event::on(CartController::className(), CartController::EVENT_ACTION_ADD, [self::className(), 'handleCartAdd'], false);
     Event::on(CartController::className(), CartController::EVENT_ACTION_REMOVE, [self::className(), 'handleRemoveFromCart'], false);
     Event::on(CartController::className(), CartController::EVENT_ACTION_QUANTITY, [self::className(), 'handleChangeQuantity'], false);
     Event::on(CartController::className(), CartController::EVENT_ACTION_CLEAR, [self::className(), 'handleClearCart'], false);
     Event::on(Controller::className(), Controller::EVENT_PRE_DECORATOR, [self::className(), 'handleProductShow']);
     if ('shop/cart/index' === $route) {
         self::handleCartIndex();
     }
     YandexAnalyticsAssets::register(\Yii::$app->getView());
 }
Esempio n. 2
0
 /**
  * Set the currency to be used when billing users.
  *
  * @param string $currency
  * @param string|null $symbol
  */
 public static function useCurrency($currency, $symbol = null)
 {
     static::$currency = $currency;
     static::useCurrencySymbol($symbol ?: static::guessCurrencySymbol($currency));
 }