isEcommerceEnabled() public method

Returns whether ecommerce is enabled for the site.
public isEcommerceEnabled ( ) : boolean
return boolean
Exemplo n.º 1
0
 /**
  * @param bool $standalone When set to true, the Top controls will be hidden to provide better full screen view
  * @param bool $fetch
  * @param bool|string $segmentOverride
  *
  * @return string
  */
 public function realtimeMap($standalone = false, $fetch = false, $segmentOverride = false)
 {
     $this->checkUserCountryPluginEnabled();
     $idSite = Common::getRequestVar('idSite', 1, 'int');
     Piwik::checkUserHasViewAccess($idSite);
     $token_auth = Piwik::getCurrentUserTokenAuth();
     $view = new View('@UserCountryMap/realtimeMap');
     $view->mapIsStandaloneNotWidget = $standalone;
     $view->metrics = $this->getMetrics($idSite, 'range', self::REAL_TIME_WINDOW, $token_auth);
     $view->defaultMetric = 'nb_visits';
     $liveRefreshAfterMs = (int) Config::getInstance()->General['live_widget_refresh_after_seconds'] * 1000;
     $goals = APIGoals::getInstance()->getGoals($idSite);
     $site = new Site($idSite);
     $hasGoals = !empty($goals) || $site->isEcommerceEnabled();
     // maximum number of visits to be displayed in the map
     $maxVisits = Common::getRequestVar('filter_limit', 100, 'int');
     // some translations
     $locale = array('nb_actions' => Piwik::translate('VisitsSummary_NbActionsDescription'), 'local_time' => Piwik::translate('VisitTime_ColumnLocalTime'), 'from' => Piwik::translate('General_FromReferrer'), 'seconds' => Piwik::translate('UserCountryMap_Seconds'), 'seconds_ago' => Piwik::translate('UserCountryMap_SecondsAgo'), 'minutes' => Piwik::translate('UserCountryMap_Minutes'), 'minutes_ago' => Piwik::translate('UserCountryMap_MinutesAgo'), 'hours' => Piwik::translate('UserCountryMap_Hours'), 'hours_ago' => Piwik::translate('UserCountryMap_HoursAgo'), 'days_ago' => Piwik::translate('UserCountryMap_DaysAgo'), 'actions' => Piwik::translate('VisitsSummary_NbPageviewsDescription'), 'searches' => Piwik::translate('UserCountryMap_Searches'), 'goal_conversions' => Piwik::translate('UserCountryMap_GoalConversions'));
     $segment = $segmentOverride ?: Request::getRawSegmentFromRequest() ?: '';
     $params = array('period' => 'range', 'idSite' => $idSite, 'segment' => $segment, 'token_auth' => $token_auth);
     $realtimeWindow = Common::getRequestVar('realtimeWindow', self::REAL_TIME_WINDOW, 'string');
     if ($realtimeWindow != 'false') {
         // handle special value
         $params['date'] = $realtimeWindow;
     }
     $reqParams = $this->getEnrichedRequest($params, $encode = false);
     $view->config = array('metrics' => array(), 'svgBasePath' => $view->piwikUrl . 'plugins/UserCountryMap/svg/', 'liveRefreshAfterMs' => $liveRefreshAfterMs, '_' => $locale, 'reqParams' => $reqParams, 'siteHasGoals' => $hasGoals, 'maxVisits' => $maxVisits, 'changeVisitAlpha' => Common::getRequestVar('changeVisitAlpha', true, 'int'), 'removeOldVisits' => Common::getRequestVar('removeOldVisits', true, 'int'), 'showFooterMessage' => Common::getRequestVar('showFooterMessage', true, 'int'), 'showDateTime' => Common::getRequestVar('showDateTime', true, 'int'), 'doNotRefreshVisits' => Common::getRequestVar('doNotRefreshVisits', false, 'int'), 'enableAnimation' => Common::getRequestVar('enableAnimation', true, 'int'), 'forceNowValue' => Common::getRequestVar('forceNowValue', false, 'int'));
     return $view->render();
 }
Exemplo n.º 2
0
Arquivo: Get.php Projeto: piwik/piwik
 private function isEcommerceEnabled($idSite)
 {
     if (!Plugin\Manager::getInstance()->isPluginActivated('Ecommerce')) {
         return false;
     }
     $site = new Site($idSite);
     return $site->isEcommerceEnabled();
 }
Exemplo n.º 3
0
 public function configure(WidgetsList $widgetsList)
 {
     $idSite = Common::getRequestVar('idSite', null, 'int');
     $site = new Site($idSite);
     if ($site->isEcommerceEnabled()) {
         $this->addEcommerceWidgets($widgetsList);
     }
     $this->addGoalsWidgets($widgetsList, $idSite);
 }
Exemplo n.º 4
0
 protected function init()
 {
     $idSite = $this->getIdSite();
     $site = new Site($idSite);
     if ($site->isEcommerceEnabled()) {
         $this->addWidget('General_Overview', 'widgetGoalReport', array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER));
         $this->addWidget('Goals_EcommerceLog', 'getEcommerceLog');
     }
 }
Exemplo n.º 5
0
 public function isEnabled()
 {
     $idSite = Common::getRequestVar('idSite', false, 'int');
     if (empty($idSite)) {
         return false;
     }
     $site = new Site($idSite);
     return $site->isEcommerceEnabled();
 }
Exemplo n.º 6
0
Arquivo: Menu.php Projeto: cemo/piwik
 public function configureReportingMenu(MenuReporting $menu)
 {
     $idSite = Common::getRequestVar('idSite', null, 'int');
     $site = new Site($idSite);
     if ($site->isEcommerceEnabled()) {
         $ecommerceParams = array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER);
         $menu->addItem('Goals_Ecommerce', '', array(), 24);
         $menu->addItem('Goals_Ecommerce', 'General_Overview', $this->urlForAction('ecommerceReport', $ecommerceParams), 1);
         $menu->addItem('Goals_Ecommerce', 'Goals_EcommerceLog', $this->urlForAction('ecommerceLogReport'), 2);
         $menu->addItem('Goals_Ecommerce', 'Goals_Products', $this->urlForAction('products', $ecommerceParams), 3);
         $menu->addItem('Goals_Ecommerce', 'Ecommerce_Sales', $this->urlForAction('sales', $ecommerceParams), 4);
     }
 }
Exemplo n.º 7
0
 public static function configure(WidgetConfig $config)
 {
     $config->setCategoryId('Goals_Ecommerce');
     $config->setSubcategoryId('Goals_EcommerceLog');
     $config->setName('Goals_EcommerceLog');
     $idSite = Common::getRequestVar('idSite', 0, 'int');
     if (empty($idSite)) {
         $config->disable();
         return;
     }
     $site = new Site($idSite);
     $config->setIsEnabled($site->isEcommerceEnabled());
 }
Exemplo n.º 8
0
 protected function init()
 {
     $this->addWidget('Goals_GoalsOverview', 'widgetGoalsOverview');
     $idSite = $this->getIdSite();
     $goals = API::getInstance()->getGoals($idSite);
     if (count($goals) > 0) {
         foreach ($goals as $goal) {
             $name = Common::sanitizeInputValue($goal['name']);
             $params = array('idGoal' => $goal['idgoal']);
             $this->addWidget($name, 'widgetGoalReport', $params);
         }
     }
     $site = new Site($idSite);
     if ($site->isEcommerceEnabled()) {
         $this->addWidgetWithCustomCategory('Goals_Ecommerce', 'Goals_EcommerceOverview', 'widgetGoalReport', array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER));
         $this->addWidgetWithCustomCategory('Goals_Ecommerce', 'Goals_EcommerceLog', 'getEcommerceLog');
     }
 }
Exemplo n.º 9
0
 public function testSetDefaultTimezoneAndCurrencyAndExcludedQueryParametersAndExcludedIps()
 {
     // test that they return default values
     $defaultTimezone = API::getInstance()->getDefaultTimezone();
     $this->assertEquals('UTC', $defaultTimezone);
     $defaultCurrency = API::getInstance()->getDefaultCurrency();
     $this->assertEquals('USD', $defaultCurrency);
     $excludedIps = API::getInstance()->getExcludedIpsGlobal();
     $this->assertEquals('', $excludedIps);
     $excludedQueryParameters = API::getInstance()->getExcludedQueryParametersGlobal();
     $this->assertEquals('', $excludedQueryParameters);
     // test that when not specified, defaults are set as expected
     $idsite = API::getInstance()->addSite("site1", array('http://example.org'));
     $site = new Site($idsite);
     $this->assertEquals('UTC', $site->getTimezone());
     $this->assertEquals('USD', $site->getCurrency());
     $this->assertEquals('', $site->getExcludedQueryParameters());
     $this->assertEquals('', $site->getExcludedIps());
     $this->assertEquals(false, $site->isEcommerceEnabled());
     // set the global timezone and get it
     $newDefaultTimezone = 'UTC+5.5';
     API::getInstance()->setDefaultTimezone($newDefaultTimezone);
     $defaultTimezone = API::getInstance()->getDefaultTimezone();
     $this->assertEquals($newDefaultTimezone, $defaultTimezone);
     // set the default currency and get it
     $newDefaultCurrency = 'EUR';
     API::getInstance()->setDefaultCurrency($newDefaultCurrency);
     $defaultCurrency = API::getInstance()->getDefaultCurrency();
     $this->assertEquals($newDefaultCurrency, $defaultCurrency);
     // set the global IPs to exclude and get it
     $newGlobalExcludedIps = '1.1.1.*,1.1.*.*,150.1.1.1';
     API::getInstance()->setGlobalExcludedIps($newGlobalExcludedIps);
     $globalExcludedIps = API::getInstance()->getExcludedIpsGlobal();
     $this->assertEquals($newGlobalExcludedIps, $globalExcludedIps);
     // set the global URL query params to exclude and get it
     $newGlobalExcludedQueryParameters = 'PHPSESSID,blabla, TesT';
     // removed the space
     $expectedGlobalExcludedQueryParameters = 'PHPSESSID,blabla,TesT';
     API::getInstance()->setGlobalExcludedQueryParameters($newGlobalExcludedQueryParameters);
     $globalExcludedQueryParameters = API::getInstance()->getExcludedQueryParametersGlobal();
     $this->assertEquals($expectedGlobalExcludedQueryParameters, $globalExcludedQueryParameters);
     // create a website and check that default currency and default timezone are set
     // however, excluded IPs and excluded query Params are not returned
     $idsite = API::getInstance()->addSite("site1", array('http://example.org'), $ecommerce = 0, $siteSearch = 0, $searchKeywordParameters = 'test1,test2', $searchCategoryParameters = 'test2,test1', '', '', $newDefaultTimezone);
     $site = new Site($idsite);
     $this->assertEquals($newDefaultTimezone, $site->getTimezone());
     $this->assertEquals(date('Y-m-d'), $site->getCreationDate()->toString());
     $this->assertEquals($newDefaultCurrency, $site->getCurrency());
     $this->assertEquals('', $site->getExcludedIps());
     $this->assertEquals('', $site->getExcludedQueryParameters());
     $this->assertEquals('test1,test2', $site->getSearchKeywordParameters());
     $this->assertEquals('test2,test1', $site->getSearchCategoryParameters());
     $this->assertFalse($site->isSiteSearchEnabled());
     $this->assertFalse(Site::isSiteSearchEnabledFor($idsite));
     $this->assertFalse($site->isEcommerceEnabled());
     $this->assertFalse(Site::isEcommerceEnabledFor($idsite));
 }
Exemplo n.º 10
0
 private function isEcommerceEnabled($idSite)
 {
     $site = new Site($idSite);
     return $site->isEcommerceEnabled();
 }
Exemplo n.º 11
0
 public function addWidgets()
 {
     $idSite = Common::getRequestVar('idSite', null, 'int');
     // Ecommerce widgets
     $site = new Site($idSite);
     if ($site->isEcommerceEnabled()) {
         WidgetsList::add('Goals_Ecommerce', 'Goals_EcommerceOverview', 'Goals', 'widgetGoalReport', array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER));
         WidgetsList::add('Goals_Ecommerce', 'Goals_EcommerceLog', 'Goals', 'getEcommerceLog');
         foreach ($this->ecommerceReports as $widget) {
             WidgetsList::add('Goals_Ecommerce', $widget[0], $widget[1], $widget[2]);
         }
     }
     // Goals widgets
     WidgetsList::add('Goals_Goals', 'Goals_GoalsOverview', 'Goals', 'widgetGoalsOverview');
     $goals = API::getInstance()->getGoals($idSite);
     if (count($goals) > 0) {
         foreach ($goals as $goal) {
             WidgetsList::add('Goals_Goals', Common::sanitizeInputValue($goal['name']), 'Goals', 'widgetGoalReport', array('idGoal' => $goal['idgoal']));
         }
     }
 }
Exemplo n.º 12
0
 protected function getGoalCategoryName($idSite)
 {
     $site = new Site($idSite);
     return $site->isEcommerceEnabled() ? 'Goals_EcommerceAndGoalsMenu' : 'Goals_Goals';
 }
Exemplo n.º 13
0
 /**
  * Returns the Metadata for the Goals plugin API.
  * The API returns general Goal metrics: conv, conv rate and revenue globally
  * and for each goal.
  *
  * Also, this will update metadata of all other reports that have Goal segmentation
  */
 public function getReportMetadata(&$reports, $info)
 {
     $idSites = $info['idSites'];
     // Processed in AddColumnsProcessedMetricsGoal
     // These metrics will also be available for some reports, for each goal
     // Example: Conversion rate for Goal 2 for the keyword 'piwik'
     $goalProcessedMetrics = array('revenue_per_visit' => Piwik::translate('General_ColumnValuePerVisit'));
     $goalMetrics = array('nb_conversions' => Piwik::translate('Goals_ColumnConversions'), 'nb_visits_converted' => Piwik::translate('General_ColumnVisitsWithConversions'), 'conversion_rate' => Piwik::translate('General_ColumnConversionRate'), 'revenue' => Piwik::translate('General_ColumnRevenue'));
     $conversionReportMetrics = array('nb_conversions' => Piwik::translate('Goals_ColumnConversions'));
     // General Goal metrics: conversions, conv rate, revenue
     $goalsCategory = Piwik::translate('Goals_Goals');
     $reports[] = array('category' => $goalsCategory, 'name' => Piwik::translate('Goals_Goals'), 'module' => 'Goals', 'action' => 'get', 'metrics' => $goalMetrics, 'processedMetrics' => array(), 'order' => 1);
     // If only one website is selected, we add the Goal metrics
     if (count($idSites) == 1) {
         $idSite = reset($idSites);
         $goals = API::getInstance()->getGoals($idSite);
         // Add overall visits to conversion report
         $reports[] = array('category' => $goalsCategory, 'name' => Piwik::translate('Goals_VisitsUntilConv'), 'module' => 'Goals', 'action' => 'getVisitsUntilConversion', 'dimension' => Piwik::translate('Goals_VisitsUntilConv'), 'constantRowsCount' => true, 'parameters' => array(), 'metrics' => $conversionReportMetrics, 'order' => 5);
         // Add overall days to conversion report
         $reports[] = array('category' => $goalsCategory, 'name' => Piwik::translate('Goals_DaysToConv'), 'module' => 'Goals', 'action' => 'getDaysToConversion', 'dimension' => Piwik::translate('Goals_DaysToConv'), 'constantRowsCount' => true, 'parameters' => array(), 'metrics' => $conversionReportMetrics, 'order' => 10);
         foreach ($goals as $goal) {
             // Add the general Goal metrics: ie. total Goal conversions,
             // Goal conv rate or Goal total revenue.
             // This API call requires a custom parameter
             $goal['name'] = Common::sanitizeInputValue($goal['name']);
             $reports[] = array('category' => $goalsCategory, 'name' => Piwik::translate('Goals_GoalX', $goal['name']), 'module' => 'Goals', 'action' => 'get', 'parameters' => array('idGoal' => $goal['idgoal']), 'metrics' => $goalMetrics, 'processedMetrics' => false, 'order' => 50 + $goal['idgoal'] * 3);
             // Add visits to conversion report
             $reports[] = array('category' => $goalsCategory, 'name' => $goal['name'] . ' - ' . Piwik::translate('Goals_VisitsUntilConv'), 'module' => 'Goals', 'action' => 'getVisitsUntilConversion', 'dimension' => Piwik::translate('Goals_VisitsUntilConv'), 'constantRowsCount' => true, 'parameters' => array('idGoal' => $goal['idgoal']), 'metrics' => $conversionReportMetrics, 'order' => 51 + $goal['idgoal'] * 3);
             // Add days to conversion report
             $reports[] = array('category' => $goalsCategory, 'name' => $goal['name'] . ' - ' . Piwik::translate('Goals_DaysToConv'), 'module' => 'Goals', 'action' => 'getDaysToConversion', 'dimension' => Piwik::translate('Goals_DaysToConv'), 'constantRowsCount' => true, 'parameters' => array('idGoal' => $goal['idgoal']), 'metrics' => $conversionReportMetrics, 'order' => 52 + $goal['idgoal'] * 3);
         }
         $site = new Site($idSite);
         if ($site->isEcommerceEnabled()) {
             $category = Piwik::translate('Goals_Ecommerce');
             $ecommerceMetrics = array_merge($goalMetrics, array('revenue_subtotal' => Piwik::translate('General_Subtotal'), 'revenue_tax' => Piwik::translate('General_Tax'), 'revenue_shipping' => Piwik::translate('General_Shipping'), 'revenue_discount' => Piwik::translate('General_Discount'), 'items' => Piwik::translate('General_PurchasedProducts'), 'avg_order_revenue' => Piwik::translate('General_AverageOrderValue')));
             $ecommerceMetrics['nb_conversions'] = Piwik::translate('General_EcommerceOrders');
             // General Ecommerce metrics
             $reports[] = array('category' => $category, 'name' => Piwik::translate('General_EcommerceOrders'), 'module' => 'Goals', 'action' => 'get', 'parameters' => array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER), 'metrics' => $ecommerceMetrics, 'processedMetrics' => false, 'order' => 10);
             $reports[] = array('category' => $category, 'name' => Piwik::translate('General_EcommerceOrders') . ' - ' . Piwik::translate('Goals_VisitsUntilConv'), 'module' => 'Goals', 'action' => 'getVisitsUntilConversion', 'dimension' => Piwik::translate('Goals_VisitsUntilConv'), 'constantRowsCount' => true, 'metrics' => $conversionReportMetrics, 'parameters' => array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER), 'order' => 11);
             $reports[] = array('category' => $category, 'name' => Piwik::translate('General_EcommerceOrders') . ' - ' . Piwik::translate('Goals_DaysToConv'), 'module' => 'Goals', 'action' => 'getDaysToConversion', 'dimension' => Piwik::translate('Goals_DaysToConv'), 'constantRowsCount' => true, 'metrics' => $conversionReportMetrics, 'parameters' => array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER), 'order' => 12);
             // Abandoned cart general metrics
             $abandonedCartMetrics = $goalMetrics;
             $abandonedCartMetrics['nb_conversions'] = Piwik::translate('General_AbandonedCarts');
             $abandonedCartMetrics['revenue'] = Piwik::translate('Goals_LeftInCart', Piwik::translate('General_ColumnRevenue'));
             $abandonedCartMetrics['items'] = Piwik::translate('Goals_LeftInCart', Piwik::translate('Goals_Products'));
             unset($abandonedCartMetrics['nb_visits_converted']);
             // Abandoned Cart metrics
             $reports[] = array('category' => $category, 'name' => Piwik::translate('General_AbandonedCarts'), 'module' => 'Goals', 'action' => 'get', 'parameters' => array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_CART), 'metrics' => $abandonedCartMetrics, 'processedMetrics' => false, 'order' => 15);
             $reports[] = array('category' => $category, 'name' => Piwik::translate('General_AbandonedCarts') . ' - ' . Piwik::translate('Goals_VisitsUntilConv'), 'module' => 'Goals', 'action' => 'getVisitsUntilConversion', 'dimension' => Piwik::translate('Goals_VisitsUntilConv'), 'constantRowsCount' => true, 'metrics' => $conversionReportMetrics, 'parameters' => array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_CART), 'order' => 20);
             $reports[] = array('category' => $category, 'name' => Piwik::translate('General_AbandonedCarts') . ' - ' . Piwik::translate('Goals_DaysToConv'), 'module' => 'Goals', 'action' => 'getDaysToConversion', 'dimension' => Piwik::translate('Goals_DaysToConv'), 'constantRowsCount' => true, 'metrics' => $conversionReportMetrics, 'parameters' => array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_CART), 'order' => 25);
             // Product reports metadata
             $productColumns = self::getProductReportColumns();
             foreach ($this->ecommerceReports as $i => $ecommerceReport) {
                 $reports[] = array('category' => $category, 'name' => Piwik::translate($ecommerceReport[0]), 'module' => 'Goals', 'action' => $ecommerceReport[2], 'dimension' => Piwik::translate($ecommerceReport[0]), 'metrics' => $productColumns, 'processedMetrics' => false, 'order' => 30 + $i);
             }
         }
     }
     unset($goalMetrics['nb_visits_converted']);
     $reportsWithGoals = self::getAllReportsWithGoalMetrics();
     foreach ($reportsWithGoals as $reportWithGoals) {
         // Select this report from the API metadata array
         // and add the Goal metrics to it
         foreach ($reports as &$apiReportToUpdate) {
             if ($apiReportToUpdate['module'] == $reportWithGoals['module'] && $apiReportToUpdate['action'] == $reportWithGoals['action']) {
                 $apiReportToUpdate['metricsGoal'] = $goalMetrics;
                 $apiReportToUpdate['processedMetricsGoal'] = $goalProcessedMetrics;
                 break;
             }
         }
     }
 }