fix minor bug
This commit is contained in:
@@ -59,8 +59,6 @@ class Currency extends BaseAction implements EventSubscriberInterface
|
||||
*/
|
||||
public function update(CurrencyUpdateEvent $event)
|
||||
{
|
||||
$search = CurrencyQuery::create();
|
||||
|
||||
if (null !== $currency = CurrencyQuery::create()->findPk($event->getCurrencyId())) {
|
||||
|
||||
$currency
|
||||
|
||||
@@ -302,7 +302,7 @@ class Order extends BaseAction implements EventSubscriberInterface
|
||||
*/
|
||||
public function createManual(OrderManualEvent $event)
|
||||
{
|
||||
$placedOrder = $this->createOrder(
|
||||
$this->createOrder(
|
||||
$event->getDispatcher(),
|
||||
$event->getOrder(),
|
||||
$event->getCurrency(),
|
||||
|
||||
0
core/lib/Thelia/Command/ModuleDeactivateCommand.php
Executable file → Normal file
0
core/lib/Thelia/Command/ModuleDeactivateCommand.php
Executable file → Normal file
@@ -308,4 +308,4 @@ abstract class ConditionAbstract implements ConditionInterface
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,4 +271,4 @@ class MatchForTotalAmount extends ConditionAbstract
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,4 +225,4 @@ class MatchForXArticles extends ConditionAbstract
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,4 +113,4 @@ abstract class Operators
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
return array(
|
||||
|
||||
);
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
return array(
|
||||
|
||||
);
|
||||
);
|
||||
|
||||
@@ -33,9 +33,7 @@ use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\Coupon;
|
||||
use Thelia\Model\CouponQuery;
|
||||
use Thelia\Model\Lang;
|
||||
use Thelia\Model\LangQuery;
|
||||
use Thelia\Tools\I18n;
|
||||
use Thelia\Tools\Rest\ResponseRest;
|
||||
|
||||
/**
|
||||
@@ -263,8 +261,7 @@ class CouponController extends BaseAdminController
|
||||
|
||||
$html = $condition->drawBackOfficeInputs();
|
||||
$serviceId = $condition->getServiceId();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$html = '';
|
||||
$serviceId = '';
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ use Thelia\Core\Event\ProductSaleElement\ProductSaleElementCreateEvent;
|
||||
use Thelia\Core\Security\Resource\AdminResources;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Model\AccessoryQuery;
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Model\FeatureQuery;
|
||||
|
||||
@@ -16,6 +16,7 @@ use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Core\Security\Resource\AdminResources;
|
||||
use Thelia\Core\Event\Profile\ProfileEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Form\ProfileCreationForm;
|
||||
use Thelia\Form\ProfileModificationForm;
|
||||
use Thelia\Form\ProfileUpdateModuleAccessForm;
|
||||
|
||||
@@ -113,7 +113,7 @@ class SessionController extends BaseAdminController
|
||||
/**
|
||||
* we have tou find a way to send cookie
|
||||
*/
|
||||
if (intval($adminLoginForm->getForm()->get('remember_me')->getData()) > 0) {
|
||||
if (intval($form->get('remember_me')->getData()) > 0) {
|
||||
// If a remember me field if present and set in the form, create
|
||||
// the cookie thant store "remember me" information
|
||||
$this->createAdminRememberMeCookie($user);
|
||||
|
||||
@@ -16,6 +16,7 @@ use Thelia\Core\Security\Resource\AdminResources;
|
||||
use Thelia\Core\Event\Tax\TaxRuleEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Form\TaxRuleCreationForm;
|
||||
use Thelia\Form\TaxRuleModificationForm;
|
||||
use Thelia\Form\TaxRuleTaxListUpdateForm;
|
||||
|
||||
@@ -182,6 +182,4 @@ class LangCreateEvent extends LangEvent
|
||||
return $this->thousands_separator;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class ProductSaleElementEvent extends ActionEvent
|
||||
{
|
||||
public $product_sale_element = null;
|
||||
|
||||
public function __construct(ProductSaleElement $product_sale_element = null)
|
||||
public function __construct(ProductSaleElements $product_sale_element = null)
|
||||
{
|
||||
$this->product_sale_element = $product_sale_element;
|
||||
}
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Factory;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* *
|
||||
* try to instanciate the good action class
|
||||
*
|
||||
* Class ActionEventFactory
|
||||
* @package Thelia\Core\Factory
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ActionEventFactory
|
||||
{
|
||||
|
||||
/**
|
||||
* @var \Symfony\Component\HttpFoundation\Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $action;
|
||||
|
||||
/**
|
||||
* array(
|
||||
* "action.addCart" => "Thelia\Core\Event\CartAction"
|
||||
* )
|
||||
*
|
||||
* @var array key are action name and value the Event class to dispatch
|
||||
*/
|
||||
protected $className;
|
||||
|
||||
protected $defaultClassName = "Thelia\Core\Event\DefaultActionEvent";
|
||||
|
||||
public function __construct(Request $request, $action, $className)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->action = $action;
|
||||
$this->className = $className;
|
||||
}
|
||||
|
||||
public function createActionEvent()
|
||||
{
|
||||
if (array_key_exists($this->action, $this->className)) {
|
||||
$class = new \ReflectionClass($this->className[$this->action]);
|
||||
// return $class->newInstance($this->request, $this->action);
|
||||
} else {
|
||||
$class = new \ReflectionClass($this->defaultClassName);
|
||||
}
|
||||
|
||||
if ($class->isSubclassOf("Thelia\Core\Event\ActionEvent") === false) {
|
||||
throw new \RuntimeException("%s must be a subclass of Thelia\Core\Event\ActionEvent", $class->getName());
|
||||
}
|
||||
|
||||
return $class->newInstance($this->request, $this->action);
|
||||
}
|
||||
}
|
||||
@@ -53,10 +53,10 @@ class Coupon extends BaseI18nLoop implements PropelSearchLoopInterface
|
||||
new TypeCollection(
|
||||
new EnumListType(array(
|
||||
'id', 'id-reverse',
|
||||
'code', 'code-reverse',
|
||||
'title', 'title-reverse',
|
||||
'enabled', 'enabled-reverse',
|
||||
'expiration-date', 'expiration-date-reverse',
|
||||
'code', 'code-reverse',
|
||||
'title', 'title-reverse',
|
||||
'enabled', 'enabled-reverse',
|
||||
'expiration-date', 'expiration-date-reverse',
|
||||
'days-left', 'days-left-reverse',
|
||||
'usages-left', 'usages-left-reverse'
|
||||
)
|
||||
|
||||
@@ -62,7 +62,7 @@ class OrderCoupon extends BaseLoop implements PropelSearchLoopInterface
|
||||
|
||||
public function parseResults(LoopResult $loopResult)
|
||||
{
|
||||
$conditionFactory = $this->container->get('thelia.condition.factory');
|
||||
$this->container->get('thelia.condition.factory');
|
||||
|
||||
/** @var OrderCoupon $orderCoupon */
|
||||
foreach ($loopResult->getResultDataCollection() as $orderCoupon) {
|
||||
|
||||
@@ -857,7 +857,7 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL
|
||||
|
||||
$visible = $this->getVisible();
|
||||
|
||||
if ($visible !== BooleanOrBothType::ANY) $search->filterByVisible($visible ? 1 : 0);
|
||||
if ($visible !== Type\BooleanOrBothType::ANY) $search->filterByVisible($visible ? 1 : 0);
|
||||
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
|
||||
@@ -96,8 +96,6 @@ class TheliaLoop extends AbstractSmartyPlugin
|
||||
|
||||
$loop = $this->createLoopInstance($params);
|
||||
|
||||
$dummy = null;
|
||||
|
||||
return $loop->count();
|
||||
}
|
||||
|
||||
|
||||
@@ -354,7 +354,8 @@ abstract class CouponAbstract implements CouponInterface
|
||||
*
|
||||
* @return string HTML string
|
||||
*/
|
||||
public function drawBackOfficeInputs() {
|
||||
public function drawBackOfficeInputs()
|
||||
{
|
||||
return $this->facade->getParser()->render('coupon/type-fragments/remove-x.html', [
|
||||
'label' => $this->getInputName(),
|
||||
'fieldName' => self::INPUT_AMOUNT_NAME,
|
||||
|
||||
@@ -145,7 +145,7 @@ class CouponCreationForm extends BaseForm
|
||||
/**
|
||||
* Validate a date entered with the default Language date format.
|
||||
*
|
||||
* @param string $value
|
||||
* @param string $value
|
||||
* @param ExecutionContextInterface $context
|
||||
*/
|
||||
public function checkLocalizedDate($value, ExecutionContextInterface $context)
|
||||
|
||||
@@ -17,7 +17,6 @@ use Thelia\Model\Base\AreaDeliveryModuleQuery as BaseAreaDeliveryModuleQuery;
|
||||
class AreaDeliveryModuleQuery extends BaseAreaDeliveryModuleQuery
|
||||
{
|
||||
|
||||
|
||||
public function findByCountryAndModule(Country $country, Module $module)
|
||||
{
|
||||
$response = null;
|
||||
|
||||
@@ -56,9 +56,21 @@ class Content extends BaseContent
|
||||
|
||||
public function setDefaultFolder($folderId)
|
||||
{
|
||||
/* ContentFolderQuery::create()
|
||||
->filterByContentId($this->getId)
|
||||
->update(array("DefaultFolder" => 0));*/
|
||||
// Unset previous category
|
||||
ContentFolderQuery::create()
|
||||
->filterByContentId($this->getId())
|
||||
->filterByDefaultFolder(true)
|
||||
->find()
|
||||
->setByDefault(false)
|
||||
->save();
|
||||
|
||||
// Set new default category
|
||||
ContentFolderQuery::create()
|
||||
->filterByContentId($this->getId())
|
||||
->filterByFolderId($folderId)
|
||||
->find()
|
||||
->setByDefault(true)
|
||||
->save();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -1,203 +1,201 @@
|
||||
<?php
|
||||
/**********************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/**********************************************************************************/
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Propel\Runtime\Propel;
|
||||
use Thelia\Model\Base\Coupon as BaseCoupon;
|
||||
use Thelia\Model\Exception\InvalidArgumentException;
|
||||
use Thelia\Model\Map\CouponTableMap;
|
||||
|
||||
/**
|
||||
* Used to provide an effect (mostly a discount)
|
||||
* at the end of the Customer checkout tunnel
|
||||
* It will be usable for a Customer only if it matches the Coupon criteria (Rules)
|
||||
*
|
||||
* @package Coupon
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class Coupon extends BaseCoupon
|
||||
{
|
||||
|
||||
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
|
||||
/**
|
||||
* Create or Update this Coupon
|
||||
*
|
||||
* @param string $code Coupon Code
|
||||
* @param string $title Coupon title
|
||||
* @param array $effects Ready to be serialized in JSON effect params
|
||||
* @param string $type Coupon type
|
||||
* @param bool $isRemovingPostage Is removing Postage
|
||||
* @param string $shortDescription Coupon short description
|
||||
* @param string $description Coupon description
|
||||
* @param boolean $isEnabled Enable/Disable
|
||||
* @param \DateTime $expirationDate Coupon expiration date
|
||||
* @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
|
||||
*/
|
||||
public function createOrUpdate($code, $title, array $effects, $type, $isRemovingPostage, $shortDescription, $description, $isEnabled, $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $maxUsage, $defaultSerializedRule, $locale = null)
|
||||
{
|
||||
$this
|
||||
->setCode($code)
|
||||
->setType($type)
|
||||
->setEffects($effects)
|
||||
->setIsRemovingPostage($isRemovingPostage)
|
||||
->setIsEnabled($isEnabled)
|
||||
->setExpirationDate($expirationDate)
|
||||
->setIsAvailableOnSpecialOffers($isAvailableOnSpecialOffers)
|
||||
->setIsCumulative($isCumulative)
|
||||
->setMaxUsage($maxUsage)
|
||||
->setLocale($locale)
|
||||
->setTitle($title)
|
||||
->setShortDescription($shortDescription)
|
||||
->setDescription($description);
|
||||
|
||||
// If no rule given, set default rule
|
||||
if (null === $this->getSerializedConditions()) {
|
||||
$this->setSerializedConditions($defaultSerializedRule);
|
||||
}
|
||||
|
||||
$this->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create or Update this coupon condition
|
||||
*
|
||||
* @param string $serializableConditions Serialized conditions ready to be saved
|
||||
* @param string $locale Coupon Language code ISO (ex: fr_FR)
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createOrUpdateConditions($serializableConditions, $locale)
|
||||
{
|
||||
$this->setSerializedConditions($serializableConditions);
|
||||
|
||||
// Set object language (i18n)
|
||||
if (!is_null($locale)) {
|
||||
$this->setLocale($locale);
|
||||
}
|
||||
|
||||
$this->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Coupon amount
|
||||
*
|
||||
* @param float $amount Amount deduced from the Cart
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAmount($amount)
|
||||
{
|
||||
$effects = $this->unserializeEffects($this->getSerializedEffects());
|
||||
$effects['amount'] = floatval($amount);
|
||||
$this->setEffects($effects);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount removed from the coupon to the cart
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getAmount()
|
||||
{
|
||||
$amount = $this->getEffects()['amount'];
|
||||
|
||||
return floatval($amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Coupon effects
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
public function getEffects()
|
||||
{
|
||||
$effects = $this->unserializeEffects($this->getSerializedEffects());
|
||||
|
||||
if (null === $effects['amount']) {
|
||||
throw new InvalidArgumentException('Missing key \'amount\' in Coupon effect coming from database');
|
||||
}
|
||||
|
||||
return $effects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Coupon effects
|
||||
*
|
||||
* @param array $effects Effect ready to be serialized
|
||||
* Needs at least the key 'amount'
|
||||
* with the amount removed from the cart
|
||||
*
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @return $this
|
||||
*/
|
||||
public function setEffects(array $effects)
|
||||
{
|
||||
if (null === $effects['amount']) {
|
||||
throw new InvalidArgumentException('Missing key \'amount\' in Coupon effect ready to be serialized array');
|
||||
}
|
||||
|
||||
$this->setSerializedEffects($this->serializeEffects($effects));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return unserialized effects
|
||||
*
|
||||
* @param string $serializedEffects Serialized effect string to unserialize
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function unserializeEffects($serializedEffects)
|
||||
{
|
||||
$effects = json_decode($serializedEffects, true);
|
||||
|
||||
return $effects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return serialized effects
|
||||
*
|
||||
* @param array $unserializedEffects Unserialized array string to serialize
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function serializeEffects(array $unserializedEffects)
|
||||
{
|
||||
$effects = json_encode($unserializedEffects);
|
||||
|
||||
return $effects;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
/**********************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/**********************************************************************************/
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Thelia\Model\Base\Coupon as BaseCoupon;
|
||||
use Thelia\Model\Exception\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Used to provide an effect (mostly a discount)
|
||||
* at the end of the Customer checkout tunnel
|
||||
* It will be usable for a Customer only if it matches the Coupon criteria (Rules)
|
||||
*
|
||||
* @package Coupon
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class Coupon extends BaseCoupon
|
||||
{
|
||||
|
||||
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
|
||||
/**
|
||||
* Create or Update this Coupon
|
||||
*
|
||||
* @param string $code Coupon Code
|
||||
* @param string $title Coupon title
|
||||
* @param array $effects Ready to be serialized in JSON effect params
|
||||
* @param string $type Coupon type
|
||||
* @param bool $isRemovingPostage Is removing Postage
|
||||
* @param string $shortDescription Coupon short description
|
||||
* @param string $description Coupon description
|
||||
* @param boolean $isEnabled Enable/Disable
|
||||
* @param \DateTime $expirationDate Coupon expiration date
|
||||
* @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
|
||||
*/
|
||||
public function createOrUpdate($code, $title, array $effects, $type, $isRemovingPostage, $shortDescription, $description, $isEnabled, $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $maxUsage, $defaultSerializedRule, $locale = null)
|
||||
{
|
||||
$this
|
||||
->setCode($code)
|
||||
->setType($type)
|
||||
->setEffects($effects)
|
||||
->setIsRemovingPostage($isRemovingPostage)
|
||||
->setIsEnabled($isEnabled)
|
||||
->setExpirationDate($expirationDate)
|
||||
->setIsAvailableOnSpecialOffers($isAvailableOnSpecialOffers)
|
||||
->setIsCumulative($isCumulative)
|
||||
->setMaxUsage($maxUsage)
|
||||
->setLocale($locale)
|
||||
->setTitle($title)
|
||||
->setShortDescription($shortDescription)
|
||||
->setDescription($description);
|
||||
|
||||
// If no rule given, set default rule
|
||||
if (null === $this->getSerializedConditions()) {
|
||||
$this->setSerializedConditions($defaultSerializedRule);
|
||||
}
|
||||
|
||||
$this->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create or Update this coupon condition
|
||||
*
|
||||
* @param string $serializableConditions Serialized conditions ready to be saved
|
||||
* @param string $locale Coupon Language code ISO (ex: fr_FR)
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function createOrUpdateConditions($serializableConditions, $locale)
|
||||
{
|
||||
$this->setSerializedConditions($serializableConditions);
|
||||
|
||||
// Set object language (i18n)
|
||||
if (!is_null($locale)) {
|
||||
$this->setLocale($locale);
|
||||
}
|
||||
|
||||
$this->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Coupon amount
|
||||
*
|
||||
* @param float $amount Amount deduced from the Cart
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAmount($amount)
|
||||
{
|
||||
$effects = $this->unserializeEffects($this->getSerializedEffects());
|
||||
$effects['amount'] = floatval($amount);
|
||||
$this->setEffects($effects);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount removed from the coupon to the cart
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getAmount()
|
||||
{
|
||||
$amount = $this->getEffects()['amount'];
|
||||
|
||||
return floatval($amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Coupon effects
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception\InvalidArgumentException
|
||||
*/
|
||||
public function getEffects()
|
||||
{
|
||||
$effects = $this->unserializeEffects($this->getSerializedEffects());
|
||||
|
||||
if (null === $effects['amount']) {
|
||||
throw new InvalidArgumentException('Missing key \'amount\' in Coupon effect coming from database');
|
||||
}
|
||||
|
||||
return $effects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Coupon effects
|
||||
*
|
||||
* @param array $effects Effect ready to be serialized
|
||||
* Needs at least the key 'amount'
|
||||
* with the amount removed from the cart
|
||||
*
|
||||
* @throws Exception\InvalidArgumentException
|
||||
* @return $this
|
||||
*/
|
||||
public function setEffects(array $effects)
|
||||
{
|
||||
if (null === $effects['amount']) {
|
||||
throw new InvalidArgumentException('Missing key \'amount\' in Coupon effect ready to be serialized array');
|
||||
}
|
||||
|
||||
$this->setSerializedEffects($this->serializeEffects($effects));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return unserialized effects
|
||||
*
|
||||
* @param string $serializedEffects Serialized effect string to unserialize
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function unserializeEffects($serializedEffects)
|
||||
{
|
||||
$effects = json_decode($serializedEffects, true);
|
||||
|
||||
return $effects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return serialized effects
|
||||
*
|
||||
* @param array $unserializedEffects Unserialized array string to serialize
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function serializeEffects(array $unserializedEffects)
|
||||
{
|
||||
$effects = json_encode($unserializedEffects);
|
||||
|
||||
return $effects;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ class Product extends BaseProduct
|
||||
$this->setTaxRuleId($taxRuleId);
|
||||
|
||||
// Create the default product sale element of this product
|
||||
$sale_elements = $this->createProductSaleElement($con, $baseWeight, $basePrice, $basePrice, $priceCurrencyId, true);
|
||||
$this->createProductSaleElement($con, $baseWeight, $basePrice, $basePrice, $priceCurrencyId, true);
|
||||
|
||||
// Store all the stuff !
|
||||
$con->commit();
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Thelia\Model\Base\ProductSaleElements as BaseProductSaleElements;
|
||||
use Thelia\Model\Tools\ProductPriceTools;
|
||||
use Thelia\TaxEngine\Calculator;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Thelia\Model;
|
||||
|
||||
use Propel\Runtime\Exception\PropelException;
|
||||
use Thelia\Exception\TaxEngineException;
|
||||
use Thelia\Model\Base\Tax as BaseTax;
|
||||
use Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
|
||||
@@ -119,7 +119,7 @@ trait PositionManagementTrait
|
||||
$result->setDispatcher($this->getDispatcher())->setPosition($my_position)->save($cnx);
|
||||
|
||||
$cnx->commit();
|
||||
} catch (Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
$cnx->rollback();
|
||||
}
|
||||
}
|
||||
@@ -185,7 +185,7 @@ trait PositionManagementTrait
|
||||
;
|
||||
|
||||
$cnx->commit();
|
||||
} catch (Exception $e) {
|
||||
} catch (\Exception $e) {
|
||||
$cnx->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,6 @@ class ContentTest extends BaseLoopTestor
|
||||
$content = ContentQuery::create()->findOne();
|
||||
if (null === $content) {
|
||||
$content = new \Thelia\Model\Content();
|
||||
$content->setDefaultFolder(0);
|
||||
$content->setVisible(1);
|
||||
$content->setTitle('foo');
|
||||
$content->save();
|
||||
|
||||
Reference in New Issue
Block a user