save if producSaleElements is in promo or not
This commit is contained in:
@@ -65,7 +65,7 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
|||||||
->filterByProductSaleElementsId($productSaleElementsId)
|
->filterByProductSaleElementsId($productSaleElementsId)
|
||||||
->findOne();
|
->findOne();
|
||||||
|
|
||||||
$this->doAddItem($cart, $productId, $productSaleElementsId, $quantity, $productPrice);
|
$this->doAddItem($cart, $productId, $productPrice->getProductSaleElements(), $quantity, $productPrice);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($append && $cartItem !== null) {
|
if ($append && $cartItem !== null) {
|
||||||
@@ -166,17 +166,18 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
|||||||
* @param float $quantity
|
* @param float $quantity
|
||||||
* @param ProductPrice $productPrice
|
* @param ProductPrice $productPrice
|
||||||
*/
|
*/
|
||||||
protected function doAddItem(\Thelia\Model\Cart $cart, $productId, $productSaleElementsId, $quantity, ProductPrice $productPrice)
|
protected function doAddItem(\Thelia\Model\Cart $cart, $productId, \Thelia\Model\ProductSaleElements $productSaleElements, $quantity, ProductPrice $productPrice)
|
||||||
{
|
{
|
||||||
$cartItem = new CartItem();
|
$cartItem = new CartItem();
|
||||||
$cartItem->setDisptacher($this->getDispatcher());
|
$cartItem->setDisptacher($this->getDispatcher());
|
||||||
$cartItem
|
$cartItem
|
||||||
->setCart($cart)
|
->setCart($cart)
|
||||||
->setProductId($productId)
|
->setProductId($productId)
|
||||||
->setProductSaleElementsId($productSaleElementsId)
|
->setProductSaleElementsId($productSaleElements->getId())
|
||||||
->setQuantity($quantity)
|
->setQuantity($quantity)
|
||||||
->setPrice($productPrice->getPrice())
|
->setPrice($productPrice->getPrice())
|
||||||
->setPromoPrice($productPrice->getPromoPrice())
|
->setPromoPrice($productPrice->getPromoPrice())
|
||||||
|
->setPromo($productSaleElements->getPromo())
|
||||||
->setPriceEndOfLife(time() + ConfigQuery::read("cart.priceEOF", 60*60*24*30))
|
->setPriceEndOfLife(time() + ConfigQuery::read("cart.priceEOF", 60*60*24*30))
|
||||||
->save();
|
->save();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,16 +44,18 @@ class Cart extends BaseCart
|
|||||||
$item->setQuantity($cartItem->getQuantity());
|
$item->setQuantity($cartItem->getQuantity());
|
||||||
$item->setProductSaleElements($productSaleElements);
|
$item->setProductSaleElements($productSaleElements);
|
||||||
if ($currentDateTime <= $cartItem->getPriceEndOfLife()) {
|
if ($currentDateTime <= $cartItem->getPriceEndOfLife()) {
|
||||||
$item->setPrice($cartItem->getPrice());
|
$item->setPrice($cartItem->getPrice())
|
||||||
$item->setPromoPrice($cartItem->getPromoPrice());
|
->setPromoPrice($cartItem->getPromoPrice())
|
||||||
|
->setPromo($productSaleElements->getPromo())
|
||||||
// TODO : new price EOF or duplicate current priceEOF from $cartItem ?
|
// TODO : new price EOF or duplicate current priceEOF from $cartItem ?
|
||||||
$item->setPriceEndOfLife($cartItem->getPriceEndOfLife());
|
->setPriceEndOfLife($cartItem->getPriceEndOfLife());
|
||||||
} else {
|
} else {
|
||||||
$productPrices = ProductPriceQuery::create()->filterByProductSaleElements($productSaleElements)->findOne();
|
$productPrices = ProductPriceQuery::create()->filterByProductSaleElements($productSaleElements)->findOne();
|
||||||
|
|
||||||
$item->setPrice($productPrices->getPrice());
|
$item->setPrice($productPrices->getPrice())
|
||||||
$item->setPromoPrice($productPrices->getPromoPrice());
|
->setPromoPrice($productPrices->getPromoPrice())
|
||||||
$item->setPriceEndOfLife(time() + ConfigQuery::read("cart.priceEOF", 60*60*24*30));
|
->setPromo($productSaleElements->getPromo())
|
||||||
|
->setPriceEndOfLife(time() + ConfigQuery::read("cart.priceEOF", 60*60*24*30));
|
||||||
}
|
}
|
||||||
$item->save();
|
$item->save();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user