Free shipping for selected countries and/or shipping methods

This commit is contained in:
Franck Allimant
2014-05-15 20:25:22 +02:00
parent 32542efe28
commit 392abff271
31 changed files with 414 additions and 106 deletions

View File

@@ -25,6 +25,8 @@ namespace Thelia\Model;
use Propel\Runtime\Propel;
use Thelia\Model\Base\Coupon as BaseCoupon;
use Thelia\Model\Base\CouponCountryQuery;
use Thelia\Model\Base\CouponModuleQuery;
use Thelia\Model\Exception\InvalidArgumentException;
use Thelia\Model\Map\CouponTableMap;
use Thelia\Model\Tools\ModelEventDispatcherTrait;
@@ -127,11 +129,13 @@ class Coupon extends BaseCoupon
;
}
$con->commit();
} catch (\Exception $ex) {
$con->rollback();
$con->rollback();
throw $ex;
throw $ex;
}
}
@@ -248,4 +252,21 @@ class Coupon extends BaseCoupon
return $effects;
}
/**
* Return the countries for which free shipping is valid
* @return array|mixed|\Propel\Runtime\Collection\ObjectCollection
*/
public function getFreeShippingForCountries() {
return CouponCountryQuery::create()->filterByCouponId($this->getId())->find();
}
/**
* Return the modules for which free shipping is valid
*
* @return array|mixed|\Propel\Runtime\Collection\ObjectCollection
*/
public function getFreeShippingForModules() {
return CouponModuleQuery::create()->filterByCouponId($this->getId())->find();
}
}