Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions PiwikTracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ public function addEcommerceItem($sku, $name = '', $category = '', $price = 0.0,

$price = $this->forceDotAsSeparatorForDecimalPoint($price);

$this->ecommerceItems[$sku] = array($sku, $name, $category, $price, $quantity);
$this->ecommerceItems[] = array($sku, $name, $category, $price, $quantity);
}

/**
Expand Down Expand Up @@ -878,8 +878,10 @@ public function getUrlTrackEcommerceOrder(

/**
* Returns URL used to track Ecommerce orders
*
* Calling this function will reinitializes the property ecommerceItems to empty array
* so items will have to be added again via addEcommerceItem()
*
* @ignore
*/
protected function getUrlTrackEcommerce($grandTotal, $subTotal = 0.0, $tax = 0.0, $shipping = 0.0, $discount = 0.0)
Expand Down Expand Up @@ -911,12 +913,7 @@ protected function getUrlTrackEcommerce($grandTotal, $subTotal = 0.0, $tax = 0.0
$url .= '&ec_dt=' . $discount;
}
if (!empty($this->ecommerceItems)) {
// Removing the SKU index in the array before JSON encoding
$items = array();
foreach ($this->ecommerceItems as $item) {
$items[] = $item;
}
$url .= '&ec_items=' . urlencode(json_encode($items));
$url .= '&ec_items=' . urlencode(json_encode($this->ecommerceItems));
}
$this->ecommerceItems = array();

Expand Down Expand Up @@ -1906,4 +1903,4 @@ function Piwik_getUrlTrackGoal($idSite, $idGoal, $revenue = 0.0)
$tracker = new PiwikTracker($idSite);

return $tracker->getUrlTrackGoal($idGoal, $revenue);
}
}