Working : coupon creation : add default rule (thelia.constraint.rule.available_for_everyone)

This commit is contained in:
gmorel
2013-09-23 23:04:00 +02:00
parent e4658d2fa2
commit d0f20cca1d
12 changed files with 154 additions and 156 deletions

View File

@@ -63,11 +63,12 @@ class Coupon extends BaseCoupon
* @param boolean $isAvailableOnSpecialOffers Is available on special offers
* @param boolean $isCumulative Is cumulative
* @param int $maxUsage Coupon quantity
* @param string $defaultSerializedRule Serialized default rule added if none found
* @param string $locale Coupon Language code ISO (ex: fr_FR)
*
* @throws \Exception
*/
function createOrUpdate($code, $title, $amount, $type, $isRemovingPostage, $shortDescription, $description, $isEnabled, $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $maxUsage, $locale = null)
function createOrUpdate($code, $title, $amount, $type, $isRemovingPostage, $shortDescription, $description, $isEnabled, $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $maxUsage, $defaultSerializedRule, $locale = null)
{
$this->setCode($code)
->setTitle($title)
@@ -82,6 +83,11 @@ class Coupon extends BaseCoupon
->setIsCumulative($isCumulative)
->setMaxUsage($maxUsage);
// If no rule given, set default rule
if (null === $this->getSerializedRules()) {
$this->setSerializedRules($defaultSerializedRule);
}
// Set object language (i18n)
if (!is_null($locale)) {
$this->setLocale($locale);