Skip to content

Commit

Permalink
Merge pull request #53 from elgentos/WouterSteen-patch-5
Browse files Browse the repository at this point in the history
Loop over $data items instead of hardcoded param set
  • Loading branch information
WouterSteen authored Mar 25, 2024
2 parents 61ab6dc + e34551b commit 647410d
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions Model/GAClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,23 +140,11 @@ public function setTrackingData(\Magento\Framework\DataObject $data)
*/
public function setTransactionData($data)
{
$this->getPurchaseEvent()
->setTransactionId($data->getTransactionId())
->setCurrency($data->getCurrency())
->setValue($data->getRevenue())
->setTax($data->getTax())
->setShipping($data->getShipping());

$this->getPurchaseEvent()->setParamValue('session_id', $data->getSessionId());
$this->getPurchaseEvent()->setParamValue('timestamp_micros', $this->getMicroTime());

if ($data->getAffiliation()) {
$this->getPurchaseEvent()->setAffiliation($data->getAffiliation());
foreach ($data->getData() as $key => $param) {
$this->getPurchaseEvent()->setParamValue($key, $param);
}

if ($data->getCouponCode()) {
$this->getPurchaseEvent()->setCouponCode($data->getCouponCode());
}
$this->getPurchaseEvent()->setParamValue('timestamp_micros', $this->getMicroTime());
}

/**
Expand Down

0 comments on commit 647410d

Please sign in to comment.