public function checkNoDuplicateAddresses(Event\ValidateEvent $event)
 {
     $addresses = array();
     foreach ($event->getOrder()->addresses as $address) {
         if (!array_key_exists($address->type, $addresses)) {
             $addresses[$address->type] = 0;
         }
         $addresses[$address->type]++;
     }
     foreach ($addresses as $type => $num) {
         if ($num > 1) {
             $event->addError(sprintf('An order may only have one address per type, there are %i `%s` addresses', $num, $type));
         }
     }
 }
 /**
  * Run basic validation on the order before it is created.
  *
  * @param  Event\ValidateEvent $event The event object
  */
 public function checkProperties(Event\ValidateEvent $event)
 {
     $order = $event->getOrder();
     if (!$order->status) {
         $event->addError('Order must have a status set');
     } else {
         if (!$order->status instanceof Status) {
             $event->addError('Order status must be an instance of Order\\Status\\Status');
         }
     }
     if (!$order->type) {
         $event->addError('Order must have a type set');
     }
     if (!$order->currencyID) {
         $event->addError('Order must have a currency ID');
     }
     if (count($order->getItems()) <= 0) {
         $event->addError('Order must have items set');
     }
     if (!$this->_validateTax($order)) {
         $event->addError('Tax calculation error');
     }
 }
 public function checkItemSet(Event\ValidateEvent $event)
 {
     if (count($event->getOrder()->items) < 1) {
         $event->addError('Order must have at least one item to be created');
     }
 }