diff --git a/core/lib/Thelia/Action/Cart.php b/core/lib/Thelia/Action/Cart.php
index 56e233fb3..da4ff8706 100644
--- a/core/lib/Thelia/Action/Cart.php
+++ b/core/lib/Thelia/Action/Cart.php
@@ -51,7 +51,7 @@ class Cart extends BaseAction implements EventSubscriberInterface
$customer = $cart->getCustomer();
$discount = 0;
- if(null !== $customer && $customer->getDiscount() > 0) {
+ if (null !== $customer && $customer->getDiscount() > 0) {
$discount = $customer->getDiscount();
}
@@ -160,7 +160,7 @@ class Cart extends BaseAction implements EventSubscriberInterface
$customer = $cart->getCustomer();
$discount = 0;
- if(null !== $customer && $customer->getDiscount() > 0) {
+ if (null !== $customer && $customer->getDiscount() > 0) {
$discount = $customer->getDiscount();
}
diff --git a/core/lib/Thelia/Cart/CartTrait.php b/core/lib/Thelia/Cart/CartTrait.php
index 9c969683d..c3cb403c8 100644
--- a/core/lib/Thelia/Cart/CartTrait.php
+++ b/core/lib/Thelia/Cart/CartTrait.php
@@ -112,7 +112,8 @@ trait CartTrait
*/
protected function duplicateCart(EventDispatcherInterface $dispatcher, CartModel $cart, Session $session, Customer $customer = null)
{
- $newCart = $cart->duplicate($this->generateCookie($session), $customer, $dispatcher);
+ $currency = $session->getCurrency();
+ $newCart = $cart->duplicate($this->generateCookie($session), $customer, $currency, $dispatcher);
$session->setCart($newCart->getId());
$cartEvent = new CartEvent($newCart);
diff --git a/core/lib/Thelia/Config/Resources/form.xml b/core/lib/Thelia/Config/Resources/form.xml
index f24363b65..27e169b7c 100644
--- a/core/lib/Thelia/Config/Resources/form.xml
+++ b/core/lib/Thelia/Config/Resources/form.xml
@@ -1,132 +1,132 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/core/lib/Thelia/Controller/Admin/AdvancedConfigurationController.php b/core/lib/Thelia/Controller/Admin/AdvancedConfigurationController.php
index 179c64183..32dee27fe 100644
--- a/core/lib/Thelia/Controller/Admin/AdvancedConfigurationController.php
+++ b/core/lib/Thelia/Controller/Admin/AdvancedConfigurationController.php
@@ -19,7 +19,6 @@ use Thelia\Core\Security\Resource\AdminResources;
use Thelia\Form\Cache\AssetsFlushForm;
use Thelia\Form\Cache\CacheFlushForm;
use Thelia\Form\Cache\ImagesAndDocumentsCacheFlushForm;
-use Thelia\Form\Exception\FormValidationException;
use Thelia\Log\Tlog;
use Thelia\Model\ConfigQuery;
diff --git a/core/lib/Thelia/Core/Template/Loop/Module.php b/core/lib/Thelia/Core/Template/Loop/Module.php
index 638de06f1..b10c1f1ad 100644
--- a/core/lib/Thelia/Core/Template/Loop/Module.php
+++ b/core/lib/Thelia/Core/Template/Loop/Module.php
@@ -173,8 +173,7 @@ class Module extends BaseI18nLoop implements PropelSearchLoopInterface
new \ReflectionClass($module->getFullNamespace());
$exists = true;
- }
- catch(\ReflectionException $ex) {
+ } catch (\ReflectionException $ex) {
$exists = false;
}
diff --git a/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php b/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php
index 225a4e9b8..78e740d61 100644
--- a/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php
+++ b/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php
@@ -168,7 +168,6 @@ class ProductSaleElements extends BaseLoop implements PropelSearchLoopInterface
$taxedPromoPrice = null;
}
-
$loopResultRow
->set("ID" , $PSEValue->getId())
->set("QUANTITY" , $PSEValue->getQuantity())
diff --git a/core/lib/Thelia/Model/Cart.php b/core/lib/Thelia/Model/Cart.php
index eac891986..aab17db46 100644
--- a/core/lib/Thelia/Model/Cart.php
+++ b/core/lib/Thelia/Model/Cart.php
@@ -18,7 +18,7 @@ class Cart extends BaseCart
* @param Customer $customer
* @return Cart
*/
- public function duplicate($token, Customer $customer = null, EventDispatcherInterface $dispatcher)
+ public function duplicate($token, Customer $customer = null, Currency $currency = null, EventDispatcherInterface $dispatcher)
{
$cartItems = $this->getCartItems();
@@ -26,11 +26,21 @@ class Cart extends BaseCart
$cart->setAddressDeliveryId($this->getAddressDeliveryId());
$cart->setAddressInvoiceId($this->getAddressInvoiceId());
$cart->setToken($token);
- // TODO : set current Currency
- $cart->setCurrencyId($this->getCurrencyId());
+ $discount = 0;
+
+ if (null === $currency) {
+ $currencyQuery = CurrencyQuery::create();
+ $currency = $currencyQuery->findPk($this->getCurrencyId()) ?: $currencyQuery->findOneByByDefault(1);
+ }
+
+ $cart->setCurrency($currency);
if ($customer) {
$cart->setCustomer($customer);
+
+ if ($customer->getDiscount() > 0) {
+ $discount = $customer->getDiscount();
+ }
}
$cart->save();
@@ -50,25 +60,18 @@ class Cart extends BaseCart
$item->setProductId($cartItem->getProductId());
$item->setQuantity($cartItem->getQuantity());
$item->setProductSaleElements($productSaleElements);
- if ($currentDateTime <= $cartItem->getPriceEndOfLife()) {
- $item->setPrice($cartItem->getPrice())
- ->setPromoPrice($cartItem->getPromoPrice())
- ->setPromo($productSaleElements->getPromo())
- // TODO : new price EOF or duplicate current priceEOF from $cartItem ?
- ->setPriceEndOfLife($cartItem->getPriceEndOfLife());
- } else {
- $productPrices = ProductPriceQuery::create()->filterByProductSaleElements($productSaleElements)->findOne();
+ $prices = $productSaleElements->getPricesByCurrency($currency, $discount);
+ $item
+ ->setPrice($prices->getPrice())
+ ->setPromoPrice($prices->getPromoPrice())
+ ->setPromo($productSaleElements->getPromo());
- $item->setPrice($productPrices->getPrice())
- ->setPromoPrice($productPrices->getPromoPrice())
- ->setPromo($productSaleElements->getPromo())
- ->setPriceEndOfLife(time() + ConfigQuery::read("cart.priceEOF", 60*60*24*30));
- }
$item->save();
$dispatcher->dispatch(TheliaEvents::CART_ITEM_DUPLICATE, new CartItemDuplicationItem($item, $cartItem));
}
}
+ $this->delete();
return $cart;
}
diff --git a/core/lib/Thelia/Model/Module.php b/core/lib/Thelia/Model/Module.php
index d599d7d87..c5b7257c3 100644
--- a/core/lib/Thelia/Model/Module.php
+++ b/core/lib/Thelia/Model/Module.php
@@ -165,7 +165,8 @@ class Module extends BaseModule
/**
* @return true if this module is a delivery module
*/
- public function isDeliveryModule() {
+ public function isDeliveryModule()
+ {
$moduleReflection = new \ReflectionClass($this->getFullNamespace());
return $moduleReflection->implementsInterface("Thelia\Module\DeliveryModuleInterface");
@@ -174,17 +175,18 @@ class Module extends BaseModule
/**
* @return true if this module is a payment module
*/
- public function isPayementModule() {
+ public function isPayementModule()
+ {
$moduleReflection = new \ReflectionClass($this->getFullNamespace());
return $moduleReflection->implementsInterface("Thelia\Module\PaymentModuleInterface");
}
-
/**
* @return BaseModule a new module instance.
*/
- public function createInstance() {
+ public function createInstance()
+ {
$moduleClass = new \ReflectionClass($this->getFullNamespace());
return $moduleClass->newInstance();