public function findByCountryAndModule(Country $country, Module $module) { $response = null; if (null !== $country->getAreaId()) { $response = $this->filterByAreaId($country->getAreaId())->filterByModule($module)->findOne(); } return $response; }
/** * 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()->getSessionCart($this->getDispatcher())->getWeight(); $areaId = $country->getAreaId(); $prices = SocolissimoPriceQuery::create()->filterByAreaId($areaId)->filterByWeightMax($cartWeight, Criteria::GREATER_EQUAL)->findOne(); $freeShipping = SocolissimoDeliveryModeQuery::create()->findOneByFreeshippingActive(1); /* check if Colissimo delivers the asked area*/ if (null !== $prices || null !== $freeShipping) { return true; } return false; }
public function getPostage(Country $country) { $cartWeight = $this->getRequest()->getSession()->getSessionCart($this->getDispatcher())->getWeight(); $postage = self::getPostageAmount($country->getAreaId(), $cartWeight); return $postage; }
/** * * calculate and return delivery price * * @param Country $country * @return mixed * @throws DeliveryException */ public function getPostage(Country $country) { $cartWeight = $this->getRequest()->getSession()->getCart()->getWeight(); $postage = PricesQuery::getPostageAmount($country->getAreaId(), $cartWeight); return $postage; }
/** * Filter the query by a related \Thelia\Model\Country object * * @param \Thelia\Model\Country|ObjectCollection $country the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildAreaQuery The current query, for fluid interface */ public function filterByCountry($country, $comparison = null) { if ($country instanceof \Thelia\Model\Country) { return $this->addUsingAlias(AreaTableMap::ID, $country->getAreaId(), $comparison); } elseif ($country instanceof ObjectCollection) { return $this->useCountryQuery()->filterByPrimaryKeys($country->getPrimaryKeys())->endUse(); } else { throw new PropelException('filterByCountry() only accepts arguments of type \\Thelia\\Model\\Country or Collection'); } }
/** * Calculate and return delivery price in the shop's default currency * * @param Country $country the country to deliver to. * * @return OrderPostage the delivery price * @throws DeliveryException if the postage price cannot be calculated. */ public function getPostage(Country $country) { $areaId = $country->getAreaId(); $cart = $this->getRequest()->getSession()->getSessionCart(); /** @var CustomDeliverySlice $slice */ $postage = $this->getSlicePostage($cart, $country); if (null === $postage) { throw new DeliveryException(); } return $postage; }