getWrappedConnection()); $database->insertSql(null, array(__DIR__ . '/Config/thelia.sql')); } /** * 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) { return true; } /** * Calculate and return delivery price in the shop's default currency * * @param Country $country the country to deliver to. * * @return OrderPostage|float the delivery price * @throws DeliveryException if the postage price cannot be calculated. */ public function getPostage(Country $country) { if (! $this->isValidDelivery($country)) { throw new DeliveryException( Translator::getInstance()->trans("This module cannot be used on the current cart.") ); } $price = 0; if (null !== $chosenPlace = $this->getRequest()->get(('pdr-choosen-day'))) { $placeId = PdrScheduleQuery::create()->findOneById($chosenPlace)->getIdPlace(); $price = PdrPlacesQuery::create()->findOneById($placeId)->getPrice(); } return $price; } static public function getDayLabel($int) { $translator = Translator::getInstance(); $days = [ $translator->trans("Monday", [], PointRetrait::MESSAGE_DOMAIN), $translator->trans("Tuesday", [], PointRetrait::MESSAGE_DOMAIN), $translator->trans("Wednesday", [], PointRetrait::MESSAGE_DOMAIN), $translator->trans("Thursday", [], PointRetrait::MESSAGE_DOMAIN), $translator->trans("Friday", [], PointRetrait::MESSAGE_DOMAIN), $translator->trans("Saturday", [], PointRetrait::MESSAGE_DOMAIN), $translator->trans("Sunday", [], PointRetrait::MESSAGE_DOMAIN) ]; if ($int === null) return $days; else return $days[$int]; } static public function calculateRelativeDate($baseDay) { $minimumDelayBeforeOrder = PlanificationLivraison::getConfigValue(PlanificationLivraison::CONFIG_PREPARATION_DELAY, 0, "en_US"); $date = new \DateTime(); $date->add(new DateInterval('P'. $minimumDelayBeforeOrder . 'D')); $nextPossibleDay = ''; switch ($baseDay) { case 0 : $nextPossibleDay = $date->modify('next monday'); break; case 1 : $nextPossibleDay = $date->modify('next tuesday'); break; case 2 : $nextPossibleDay = $date->modify('next wednesday'); break; case 3 : $nextPossibleDay = $date->modify('next thursday'); break; case 4 : $nextPossibleDay = $date->modify('next friday'); break; case 5 : $nextPossibleDay = $date->modify('next saturday'); break; case 6 : $nextPossibleDay = $date->modify('next sunday'); break; } return $nextPossibleDay; } }