Bonjour,
j'ai modifié le module https://github.com/thelia-modules/ColissimoHomeDelivery
afin qu'il réponde à mon besoin.
Celle-ci fonctionne comme je l'attend mais j'aimerais être sur que je n'ai pas écrit n'importe quoi, n'importe comment.
use Thelia\Model\AddressQuery;
...
public function getPostage(Country $country, State $state = null)
{
$request = $this->getRequest();
$orderPostage = 0;
$freeshippingIsActive = ColissimoHomeDeliveryFreeshippingQuery::create()->findOneById(1)->getActive();
if (false === $freeshippingIsActive) {
$cartWeight = $request->getSession()->getSessionCart($this->getDispatcher())->getWeight();
$cartAmount = $request->getSession()->getSessionCart($this->getDispatcher())->getTaxedAmount($country, false);
if (null === $orderPostage = $this->getMinPostage($country, $cartWeight, $cartAmount, $request->getSession()->getLang()->getLocale())) {
throw new DeliveryException('Colissimo delivery unavailable for your cart weight or delivery country');
}
if (null !== $deliveryAddress = AddressQuery::create()->findPk(
$this->getRequest()->getSession()->getOrder()->getChoosenDeliveryAddress()
)) {
$country_id = $deliveryAddress->getCountryId();
$codePostal = $deliveryAddress->getZipcode();
$corse = substr($codePostal,0,2);
//ajout du supplement corse
if ($country_id === 64 && $corse === "20") {
$cartWeight = $request->getSession()->getSessionCart($this->getDispatcher())->getWeight();
$orderPostage = self::getPostageAmount(
$this->getAreaForCountry($country)->getId(),
$cartWeight
);
return $orderPostage = $orderPostage+24;
}
//ajout du supplement montagne et iles
if ($country_id === 64 && $codePostal == "04110" || $codePostal == "..." || ...) {
$cartWeight = $request->getSession()->getSessionCart($this->getDispatcher())->getWeight();
$postage = self::getPostageAmount(
$this->getAreaForCountry($country)->getId(),
$cartWeight
);
return $orderPostage = $orderPostage+5;
}
//autre conditions
elseif ($country_id === 5 && $codePostal == ".." == ""){}
}
}
return $orderPostage;
}
Qu'en pensez vous ?
Last edited by vz777 (05-02-2023 17:55:37)