/**
  * @param $orderNumber
  * @param $total
  *
  * @return Transaction
  */
 public function createAnalyticsTransaction($orderNumber, $total)
 {
     $transaction = new Transaction();
     $transaction->setOrderNumber($orderNumber);
     $transaction->setTotal($total);
     $this->getAnalytics()->setTransaction($transaction);
     return $transaction;
 }
 public function testSetGetTransaction()
 {
     $this->assertFalse($this->analytics->isTransactionValid());
     $transaction = new Transaction();
     $transaction->setOrderNumber('xxxx');
     $transaction->setAffiliation('Store 777');
     $transaction->setTotal(100.0);
     $transaction->setTax(10.0);
     $transaction->setShipping(5.0);
     $transaction->setCity("NYC");
     $transaction->setState("NY");
     $transaction->setCountry("USA");
     $this->analytics->setTransaction($transaction);
     $this->assertTrue($this->analytics->isTransactionValid());
     $this->assertEquals($transaction, $this->analytics->getTransaction());
     $transaction = new Transaction();
     $transaction->setAffiliation('Store 777');
     $transaction->setTotal(100.0);
     $transaction->setTax(10.0);
     $transaction->setShipping(5.0);
     $transaction->setCity("NYC");
     $transaction->setState("NY");
     $transaction->setCountry("USA");
     $this->analytics->setTransaction($transaction);
     $this->assertFalse($this->analytics->isTransactionValid());
 }
 public function testToArrayFromArray()
 {
     $transaction = new Transaction();
     $transaction->setOrderNumber('xxxx');
     $transaction->setAffiliation('Store 777');
     $transaction->setRevenue(85.0);
     $transaction->setTotal(100.0);
     $transaction->setTax(10.0);
     $transaction->setShipping(5.0);
     $transaction->setCity("NYC");
     $transaction->setState("NY");
     $transaction->setCountry("USA");
     $toArray = $transaction->toArray();
     $transaction2 = new Transaction();
     $transaction2->fromArray($toArray);
     $this->assertEquals($transaction, $transaction2);
 }
Exemple #4
0
 /**
  * @return AntiMattr\GoogleBundle\Analytics\Transaction $transaction
  */
 private function getTransactionFromSession()
 {
     $transactionArray = $this->container->get('session')->get(self::TRANSACTION_KEY);
     if (empty($transactionArray) || is_object($transactionArray)) {
         return $transactionArray;
     }
     $transaction = new Transaction();
     $transaction->fromArray($transactionArray);
     return $transaction;
 }