本文整理匯總了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);
}