예제 #1
0
 /**
  * @return array|mixed|OrderAddress
  * @throws \UnexpectedValueException
  */
 public function getDeliveryOrderAddress()
 {
     $delivery_order_address_id = $this->order->getDeliveryOrderAddressId();
     $delivery_order_address = OrderAddressQuery::create()->findPk($delivery_order_address_id);
     if ($delivery_order_address === null) {
         throw new \UnexpectedValueException("The delivery address doesn't exist");
     }
     return $delivery_order_address;
 }
예제 #2
0
 public function testAddValidEntry()
 {
     $delivery_address_id = $this->order->getDeliveryOrderAddressId();
     $delivery_address = OrderAddressQuery::create()->findPk($delivery_address_id);
     $delivery_address->setCountryId(CountryQuery::create()->findOneByIsoalpha3("FRA")->getId());
     // France metropolitan
     $this->export->addEntry($this->instance);
 }
예제 #3
0
 public static function getFromOrder(Order $order)
 {
     $translator = Translator::getInstance();
     if ($order->getDeliveryModuleId() !== TNTFrance::getModuleId()) {
         throw new \InvalidArgumentException($translator->trans("The order %id does not use the", ['id' => $order->getId()], TNTFrance::MESSAGE_DOMAIN));
     }
     $data = TNTFrance::getExtraOrderData($order->getId(), false);
     if (empty($data)) {
         throw new \InvalidArgumentException($translator->trans("No TNT data for order %id", ['id' => $order->getId()], TNTFrance::MESSAGE_DOMAIN));
     }
     $receiver = new TNTReceiver();
     $receiver->setType($data['tnt_service']);
     $receiver->setEmailAddress($order->getCustomer()->getEmail());
     if (array_key_exists('tnt_instructions', $data)) {
         $receiver->setInstructions($data['tnt_instructions']);
     }
     if (array_key_exists('tnt_phoneNumber', $data)) {
         $phoneNumber = str_replace(" ", "", $data['tnt_phoneNumber']);
         $receiver->setPhoneNumber($phoneNumber);
     }
     //todo : $receiver->setSendNotification(TNTFrance::getConfigValue(TNTFranceConfigValue::NOTIFICATION_USER));
     switch ($data['tnt_service']) {
         case 'INDIVIDUAL':
         case 'ENTERPRISE':
             $address = OrderAddressQuery::create()->findPk($order->getDeliveryOrderAddressId());
             if (null !== $address) {
                 $receiver->setName($address->getCompany())->setAddress1($address->getAddress1())->setAddress2($address->getAddress2())->setZipCode($address->getZipcode())->setCity($address->getCity())->setContactLastName($address->getLastname())->setContactFirstName($address->getFirstname());
                 if (array_key_exists('tnt_accessCode', $data)) {
                     $receiver->setAccessCode($data['tnt_accessCode']);
                 }
                 if (array_key_exists('tnt_floorNumber', $data)) {
                     $receiver->setAccessCode($data['tnt_floorNumber']);
                 }
                 if (array_key_exists('tnt_buildingId', $data)) {
                     $receiver->setAccessCode($data['tnt_buildingId']);
                 }
             }
             break;
         case 'DEPOT':
             $receiver->setTypeId($data['tnt_pexcode'])->setCity($data['tnt_depot_address']['city']);
             break;
         case 'DROPOFFPOINT':
             $receiver->setTypeId($data['tnt_exttcode']);
             break;
         default:
             throw new \InvalidArgumentException($translator->trans("TNT service %service is not valid for order %id", ['id' => $order->getId(), 'service' => $data['tnt_service']], TNTFrance::MESSAGE_DOMAIN));
     }
     return $receiver;
 }
예제 #4
0
 /**
  * @depends testCreate
  *
  * @param OrderModel $order
  */
 public function testUpdateAddress(OrderModel $order)
 {
     $deliveryRef = uniqid('DELREF');
     $orderAddress = OrderAddressQuery::create()->findPk($order->getDeliveryOrderAddressId());
     $title = $orderAddress->getCustomerTitleId() == 3 ? 1 : 3;
     $country = $orderAddress->getCountryId() == 64 ? 1 : 64;
     $orderAddressEvent = new OrderAddressEvent($title, 'B', 'C', 'D', 'E', 'F', 'G', 'H', $country, 'J', 'K');
     $orderAddressEvent->setOrderAddress($orderAddress);
     $orderAddressEvent->setOrder($order);
     $this->orderAction->updateAddress($orderAddressEvent);
     $newOrderAddress = OrderAddressQuery::create()->findPk($orderAddress->getId());
     $this->assertEquals($title, $orderAddressEvent->getOrderAddress()->getCustomerTitleId());
     $this->assertEquals('B', $orderAddressEvent->getOrderAddress()->getFirstname());
     $this->assertEquals('C', $orderAddressEvent->getOrderAddress()->getLastname());
     $this->assertEquals('D', $orderAddressEvent->getOrderAddress()->getAddress1());
     $this->assertEquals('E', $orderAddressEvent->getOrderAddress()->getAddress2());
     $this->assertEquals('F', $orderAddressEvent->getOrderAddress()->getAddress3());
     $this->assertEquals('G', $orderAddressEvent->getOrderAddress()->getZipcode());
     $this->assertEquals('H', $orderAddressEvent->getOrderAddress()->getCity());
     $this->assertEquals($country, $orderAddressEvent->getOrderAddress()->getCountryId());
     $this->assertEquals('J', $orderAddressEvent->getOrderAddress()->getPhone());
     $this->assertEquals('K', $orderAddressEvent->getOrderAddress()->getCompany());
     $this->assertEquals($title, $newOrderAddress->getCustomerTitleId());
     $this->assertEquals('B', $newOrderAddress->getFirstname());
     $this->assertEquals('C', $newOrderAddress->getLastname());
     $this->assertEquals('D', $newOrderAddress->getAddress1());
     $this->assertEquals('E', $newOrderAddress->getAddress2());
     $this->assertEquals('F', $newOrderAddress->getAddress3());
     $this->assertEquals('G', $newOrderAddress->getZipcode());
     $this->assertEquals('H', $newOrderAddress->getCity());
     $this->assertEquals($country, $newOrderAddress->getCountryId());
     $this->assertEquals('J', $newOrderAddress->getPhone());
     $this->assertEquals('K', $newOrderAddress->getCompany());
 }
예제 #5
0
 /**
  * Filter the query by a related \Thelia\Model\Order object
  *
  * @param \Thelia\Model\Order|ObjectCollection $order  the related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildOrderAddressQuery The current query, for fluid interface
  */
 public function filterByOrderRelatedByDeliveryOrderAddressId($order, $comparison = null)
 {
     if ($order instanceof \Thelia\Model\Order) {
         return $this->addUsingAlias(OrderAddressTableMap::ID, $order->getDeliveryOrderAddressId(), $comparison);
     } elseif ($order instanceof ObjectCollection) {
         return $this->useOrderRelatedByDeliveryOrderAddressIdQuery()->filterByPrimaryKeys($order->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByOrderRelatedByDeliveryOrderAddressId() only accepts arguments of type \\Thelia\\Model\\Order or Collection');
     }
 }