diff --git a/Config/module.xml b/Config/module.xml index 2e1e315..b86321a 100644 --- a/Config/module.xml +++ b/Config/module.xml @@ -15,7 +15,7 @@ en_US fr_FR - 1.0.2 + 1.0.3 Thelia diff --git a/Config/routing.xml b/Config/routing.xml index dd41cb5..4d88b93 100644 --- a/Config/routing.xml +++ b/Config/routing.xml @@ -42,7 +42,7 @@ - ChronopostPickupPoint\Controller\ChronopostPickupPointRelayController::saveAddressAction + ChronopostPickupPoint\Controller\ChronopostPickupPointFrontController::saveAddressAction diff --git a/Controller/ChronopostPickupPointFrontController.php b/Controller/ChronopostPickupPointFrontController.php new file mode 100644 index 0000000..488253a --- /dev/null +++ b/Controller/ChronopostPickupPointFrontController.php @@ -0,0 +1,37 @@ +filterByIsoalpha2($this->getRequest()->get('country'))->findOne()->getId(); + + $addr + ->setCompany($this->getRequest()->get('company')) + ->setAddress1($this->getRequest()->get('addr1')) + ->setAddress2($this->getRequest()->get('addr2')) + ->setAddress3($this->getRequest()->get('addr3')) + ->setCountryId($countryId) + ->setZipCode($this->getRequest()->get('zip')) + ->setCity($this->getRequest()->get('city')) + ->save() + ; + + $this->getRequest()->getSession()->set('ChronopostPickupPointId', $addr->getId()); + + return $this->jsonResponse($addr->getId(), 200); + } +} \ No newline at end of file diff --git a/Controller/ChronopostPickupPointRelayController.php b/Controller/ChronopostPickupPointRelayController.php index 8c279eb..9300407 100644 --- a/Controller/ChronopostPickupPointRelayController.php +++ b/Controller/ChronopostPickupPointRelayController.php @@ -5,9 +5,7 @@ use ChronopostPickupPoint\Config\ChronopostPickupPointConst; -use ChronopostPickupPoint\Model\ChronopostPickupPointOrderAddress; use Thelia\Controller\Admin\BaseAdminController; -use Thelia\Model\CountryQuery; class ChronopostPickupPointRelayController extends BaseAdminController { @@ -50,28 +48,4 @@ public function findByAddress($orderWeight, $address, $zipCode, $city, $countryC return $response->return->listePointRelais; } - - /** - * @return \Thelia\Core\HttpFoundation\Response - * @throws \Propel\Runtime\Exception\PropelException - */ - public function saveAddressAction() - { - $addr = new ChronopostPickupPointOrderAddress(); - $countryId = CountryQuery::create()->filterByIsoalpha2($this->getRequest()->get('country'))->findOne()->getId(); - - $addr - ->setCompany($this->getRequest()->get('company')) - ->setAddress1($this->getRequest()->get('addr1')) - ->setAddress2($this->getRequest()->get('addr2')) - ->setAddress3($this->getRequest()->get('addr3')) - ->setCountryId($countryId) - ->setZipCode($this->getRequest()->get('zip')) - ->setCity($this->getRequest()->get('city')) - ->save(); - - $this->getRequest()->getSession()->set('ChronopostPickupPointId', $addr->getId()); - - return $this->jsonResponse($addr->getId(), 200); - } } \ No newline at end of file