Skip to content

Commit

Permalink
Merge pull request #2 from Lurivar/master
Browse files Browse the repository at this point in the history
Fix issue when choosing relay and not connected in admin
  • Loading branch information
Lurivar authored Oct 27, 2020
2 parents c7e4d67 + b1849f2 commit cd82be6
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Config/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<language>en_US</language>
<language>fr_FR</language>
</languages>
<version>1.0.2</version>
<version>1.0.3</version>
<authors>
<author>
<name>Thelia</name>
Expand Down
2 changes: 1 addition & 1 deletion Config/routing.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
</route>

<route id="chronopost.pickup.point.set.address" path="/chronopost/pickup-point/save">
<default key="_controller">ChronopostPickupPoint\Controller\ChronopostPickupPointRelayController::saveAddressAction</default>
<default key="_controller">ChronopostPickupPoint\Controller\ChronopostPickupPointFrontController::saveAddressAction</default>
</route>

</routes>
37 changes: 37 additions & 0 deletions Controller/ChronopostPickupPointFrontController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php


namespace ChronopostPickupPoint\Controller;


use ChronopostPickupPoint\Model\ChronopostPickupPointOrderAddress;
use Thelia\Controller\Front\BaseFrontController;
use Thelia\Model\CountryQuery;

class ChronopostPickupPointFrontController extends BaseFrontController
{
/**
* @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);
}
}
26 changes: 0 additions & 26 deletions Controller/ChronopostPickupPointRelayController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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);
}
}

0 comments on commit cd82be6

Please sign in to comment.