public function miniCartBlock() { $this->loadLanguageFile('Order'); $this->order->loadAll(); $this->order->getTotal(true); return new BlockResponse('order', $this->order->toArray()); }
private function assertDefaultZoneOrder(CustomerOrder $order, Currency $currency) { $this->assertEquals(100, $order->getTotal()); $shipment = $order->getShipments()->get(0); $shipmentArray = $shipment->toArray(); $this->assertEquals(9.09, round($shipmentArray['taxAmount'], 2), 'shipment array, taxAmount'); $this->assertEquals(90.91, round($shipmentArray['amount'], 2), 'shipment array, amount'); $this->assertEquals(100.0, round($shipmentArray['amount'] + $shipmentArray['taxAmount'], 2), 'shipment array, amount + taxAmount'); $this->assertEquals(100, round($shipment->getSubTotal(true), 2), '$shipment->getSubTotal(<with taxes>)'); $this->assertEquals(90.91, round($shipment->getSubTotal(false), 2), '$shipment->getSubTotal(<without taxes>)'); $arr = $order->toArray(); $this->assertEquals(100, $arr['cartItems'][0]['displayPrice']); $this->assertEquals(100, $arr['cartItems'][0]['displaySubTotal']); // $this->assertEqual(round($arr['cartItems'][0]['itemSubTotal'], 2), 90.91); }
public function sendStatusNotifyEmail(CustomerOrder $order) { $status = $order->status->get(); $enabledStatuses = $this->config->get('EMAIL_STATUS_UPDATE_STATUSES'); $m = array('EMAIL_STATUS_UPDATE_NEW' => CustomerOrder::STATUS_NEW, 'EMAIL_STATUS_UPDATE_PROCESSING' => CustomerOrder::STATUS_PROCESSING, 'EMAIL_STATUS_UPDATE_AWAITING_SHIPMENT' => CustomerOrder::STATUS_AWAITING, 'EMAIL_STATUS_UPDATE_SHIPPED' => CustomerOrder::STATUS_SHIPPED); $sendEmail = false; foreach ($m as $configKey => $constValue) { if ($status == $constValue && array_key_exists($configKey, $enabledStatuses)) { $sendEmail = true; } } if ($this->config->get('EMAIL_STATUS_UPDATE') || $sendEmail) { $this->loadLanguageFile('Frontend'); $this->application->loadLanguageFiles(); $order->user->get()->load(); $email = new Email($this->application); $email->setUser($order->user->get()); $email->setTemplate('order.status'); $email->set('order', $order->toArray(array('payments' => true))); $email->set('shipments', $order->getShipments()->toArray()); $email->send(); } }
protected function finalizeOrder(CustomerOrder $customer_order, User $user) { $user->load(); /*if (!count($customer_order->getShipments())) { throw new Exception('No shipments in order'); }*/ $newOrder = $customer_order->finalize(); $orderArray = $customer_order->toArray(array('payments' => true)); // send order confirmation email if ($this->application->config->get('EMAIL_NEW_ORDER')) { $email = new Email($this->application); $email->setUser($user); $email->setTemplate('order.new'); $email->set('order', $orderArray); $email->send(); } // notify store admin if ($this->application->config->get('NOTIFY_NEW_ORDER')) { $email = new Email($this->application); $email->setTo($this->application->config->get('NOTIFICATION_EMAIL'), $this->application->config->get('STORE_NAME')); $email->setTemplate('notify.order'); $email->set('order', $orderArray); $email->set('user', $user->toArray()); $email->send(); } // if user hasn't wish list items order->finalize() will return null, saving null with SessionOrder causes fatal error! if ($newOrder instanceof CustomerOrder) { return true; } return false; }