public function buildArray() { $area = $this->getArea(); $prices = PricesQuery::getPrices(); if (!isset($prices[$area]) || !isset($prices[$area]["slices"])) { return array(); } $areaPrices = $prices[$area]["slices"]; ksort($areaPrices); return $areaPrices; }
/** * This method is called by the Delivery loop, to check if the current module has to be displayed to the customer. * Override it to implements your delivery rules/ * * If you return true, the delivery method will de displayed to the customer * If you return false, the delivery method will not be displayed * * @param Country $country the country to deliver to. * * @return boolean */ public function isValidDelivery(Country $country) { $cartWeight = $this->getRequest()->getSession()->getCart()->getWeight(); $areaId = $country->getAreaId(); $prices = PricesQuery::getPrices(); /* check if Predict delivers the asked area */ if (isset($prices[$areaId]) && isset($prices[$areaId]["slices"])) { $areaPrices = $prices[$areaId]["slices"]; ksort($areaPrices); /* check this weight is not too much */ end($areaPrices); $maxWeight = key($areaPrices); if ($cartWeight <= $maxWeight) { return true; } } return false; }