public function setOrderDelivery(OrderEvent $event) { if ($event->getOrder()->getDeliveryModuleId() == TNTFrance::getModuleId()) { // we have the order id $data = TNTFrance::getExtraOrderData($event->getOrder()->getCartId()); TNTFrance::setExtraOrderData($event->getOrder()->getId(), $data, false); } }
public function saveConfigurationAction() { $this->checkAuth(); $this->checkXmlHttpRequest(); $customer = $this->getSecurityContext()->getCustomerUser(); $address = TNTFrance::getCartDeliveryAddress($this->getRequest()); $order = $this->getSession()->getOrder(); $data = TNTFrance::getExtraOrderData($this->getSession()->getSessionCart()->getId()); if ($address->getCustomerId() !== $customer->getId()) { $this->accessDenied(); } if (null !== ($city = $this->getRequest()->request->get('tnt_city'))) { $address->setCity($city)->save(); } $fields = ['tnt_service', 'tnt_instructions', 'tnt_contactLastName', 'tnt_contactFirstName', 'tnt_emailAdress', 'tnt_phoneNumber', 'tnt_accessCode', 'tnt_floorNumber', 'tnt_buldingId', 'tnt_sendNotification', 'tnt_pexcode', 'tnt_depot_zipcode', 'tnt_depot_city', 'tnt_depot_address', 'tnt_xettcode', 'tnt_dop_zipcode', 'tnt_dop_city', 'tnt_dop_address']; foreach ($fields as $field) { $value = $this->getRequest()->request->get($field); if (null !== $value) { if (in_array($field, ['tnt_dop_address', 'tnt_depot_address'])) { $data[$field] = json_decode($value, true); } else { $data[$field] = $value; } } } TNTFrance::setExtraOrderData($this->getSession()->getSessionCart()->getId(), $data); // get feasibility $params = ['unavailable' => false, 'feasibility' => false]; switch ($data['tnt_service']) { case 'INDIVIDUAL': $this->checkIndividual($params, $address, $data); break; case 'ENTERPRISE': $this->checkEnterprise($params, $address, $data); break; case 'DEPOT': $this->checkDepot($params, $address, $data); break; case 'DROPOFFPOINT': $this->checkDropOffPoint($params, $address, $data); break; default: } $out = ['status' => 0, 'content' => '']; $choices = []; if ($params['feasibility']) { /** @var Feasibility $ws */ $ws = $this->getWebService('feasibility'); $ws->setZipCode($params['feasibility_zipcode'])->setCity($params['feasibility_city'])->setType($data['tnt_service']); $choices = $ws->exec(); } $cartEvent = new CartEvent($this->getRequest()->getSession()->getSessionCart($this->getDispatcher())); $this->dispatch(OrderAction::TNT_CALCUL_CART_WEIGHT, $cartEvent); /** @var \TNTFrance\WebService\Model\TNTService $tntService */ foreach ($choices as $tntService) { $tntService->setPrice(TNTFrance::calculPriceForService($tntService->getServiceCode(), $cartEvent->getCart()->getVirtualColumn('total_package'), $cartEvent->getCart()->getVirtualColumn('total_weight'))); } $out["status"] = count($choices); $out["content"] = $this->renderRaw('ajax-feasibility', ['choices' => $choices]); return $this->jsonResponse(json_encode($out)); }