public function testDefaultZoneVAT() { $taxRate = TaxRate::getNewInstance(DeliveryZone::getDefaultZoneInstance(), $this->tax, 10); $taxRate->save(); $order = CustomerOrder::getNewInstance($this->user); $order->addProduct($this->product, 1, true); $order->currency->set($this->currency); $order->save(); $this->assertEqual($order->getTotal(), 100); $order->finalize(); $this->assertDefaultZoneOrder($order, $this->currency); ActiveRecord::clearPool(); ActiveRecord::clearArrayData(); $reloaded = CustomerOrder::getInstanceById($order->getID(), true); /* debug $reloaded->getShipments(); $arr = $reloaded->toArray(); foreach($arr['cartItems'][0] as $k=>$v) if(!is_array($v)) echo $k.' : '.$v."\n"; */ $this->assertDefaultZoneOrder($reloaded, $this->currency); }
public function changeCurrency(Currency $currency, $save = true) { $this->currency->set($currency); foreach ($this->getOrderedItems() as $item) { $item->price->set($item->getProduct()->getItemPrice($item, true, $currency)); $item->setItemPrice($item->price->get()); if ($save) { $item->save(); } } if ($save) { $this->save(); } // otherwise old currency price "sticks" for this request ActiveRecord::clearArrayData(); }
protected function loadData() { ActiveRecord::clearArrayData(); $this->data = ActiveRecord::getRecordSetArray($this->table, $this->filter, $this->referencedRecords); }
/** * @role login */ public function completed() { if ($this->request->isValueSet('id')) { return new ActionRedirectResponse('checkout', 'completeExternal', array('id' => $this->request->get('id'))); } ActiveRecord::clearPool(); ActiveRecord::clearArrayData(); $order = CustomerOrder::getInstanceByID((int) $this->session->get('completedOrderID'), CustomerOrder::LOAD_DATA); $order->getTaxAmount(); $order->loadAll(); $order->getTaxAmount(); ActiveRecord::clearArrayData(); $arr = $order->toArray(); $response = new ActionResponse(); $response->set('order', $arr); $response->set('url', $this->router->createUrl(array('controller' => 'user', 'action' => 'viewOrder', 'id' => $this->session->get('completedOrderID')), true)); if (!$order->isPaid->get()) { $transactions = $order->getTransactions()->toArray(); $response->set('transactions', $transactions); } else { $response->set('files', ProductFile::getOrderFiles(select(eq('CustomerOrder.ID', $order->getID())))); } return $response; }