本文整理汇总了PHP中Piwik\Tracker\Request::getGoalRevenue方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getGoalRevenue方法的具体用法?PHP Request::getGoalRevenue怎么用?PHP Request::getGoalRevenue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Tracker\Request
的用法示例。
在下文中一共展示了Request::getGoalRevenue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: recordEcommerceGoal
/**
* Records an Ecommerce conversion in the DB. Deals with Items found in the request.
* Will deal with 2 types of conversions: Ecommerce Order and Ecommerce Cart update (Add to cart, Update Cart etc).
*
* @param array $conversion
* @param array $visitInformation
*/
protected function recordEcommerceGoal($conversion, $visitInformation)
{
if ($this->isThereExistingCartInVisit) {
Common::printDebug("There is an existing cart for this visit");
}
if ($this->isGoalAnOrder) {
$conversion['idgoal'] = self::IDGOAL_ORDER;
$conversion['idorder'] = $this->orderId;
$conversion['buster'] = Common::hashStringToInt($this->orderId);
$conversion['revenue_subtotal'] = $this->getRevenue($this->request->getParam('ec_st'));
$conversion['revenue_tax'] = $this->getRevenue($this->request->getParam('ec_tx'));
$conversion['revenue_shipping'] = $this->getRevenue($this->request->getParam('ec_sh'));
$conversion['revenue_discount'] = $this->getRevenue($this->request->getParam('ec_dt'));
$debugMessage = 'The conversion is an Ecommerce order';
} else {
$conversion['buster'] = 0;
$conversion['idgoal'] = self::IDGOAL_CART;
$debugMessage = 'The conversion is an Ecommerce Cart Update';
}
$conversion['revenue'] = $this->getRevenue($this->request->getGoalRevenue($defaultRevenue = 0));
Common::printDebug($debugMessage . ':' . var_export($conversion, true));
// INSERT or Sync items in the Cart / Order for this visit & order
$items = $this->getEcommerceItemsFromRequest();
if ($items === false) {
return;
}
$itemsCount = 0;
foreach ($items as $item) {
$itemsCount += $item[self::INTERNAL_ITEM_QUANTITY];
}
$conversion['items'] = $itemsCount;
if ($this->isThereExistingCartInVisit) {
$updateWhere = array('idvisit' => $visitInformation['idvisit'], 'idgoal' => self::IDGOAL_CART, 'buster' => 0);
$recorded = $this->updateExistingConversion($conversion, $updateWhere);
} else {
$recorded = $this->insertNewConversion($conversion, $visitInformation);
}
if ($recorded) {
$this->recordEcommerceItems($conversion, $items, $visitInformation);
}
/**
* Triggered after successfully persisting an ecommerce conversion.
*
* _Note: Subscribers should be wary of doing any expensive computation here as it may slow
* the tracker down._
*
* @param array $conversion The conversion entity that was just persisted. See what information
* it contains [here](/guides/persistence-and-the-mysql-backend#conversions).
* @param array $visitInformation The visit entity that we are tracking a conversion for. See what
* information it contains [here](/guides/persistence-and-the-mysql-backend#visits).
*/
Piwik::postEvent('Tracker.recordEcommerceGoal', array($conversion, $visitInformation));
}
示例2: onEcommerceOrderConversion
/**
* @param Request $request
* @param Visitor $visitor
* @param Action|null $action
* @param GoalManager $goalManager
*
* @return mixed|false
*/
public function onEcommerceOrderConversion(Request $request, Visitor $visitor, $action, GoalManager $goalManager)
{
$defaultRevenue = 0;
$revenue = $request->getGoalRevenue($defaultRevenue);
return $this->roundRevenueIfNeeded($revenue);
}