remove unused use statement
This commit is contained in:
@@ -29,21 +29,14 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Thelia\Core\Event\ActionEvent;
|
use Thelia\Core\Event\ActionEvent;
|
||||||
use Thelia\Core\Event\CartEvent;
|
|
||||||
use Thelia\Core\Event\TheliaEvents;
|
|
||||||
use Thelia\Core\HttpFoundation\Session\Session;
|
|
||||||
use Thelia\Form\CartAdd;
|
use Thelia\Form\CartAdd;
|
||||||
use Thelia\Model\ProductPrice;
|
use Thelia\Model\ProductPrice;
|
||||||
use Thelia\Model\ProductPriceQuery;
|
use Thelia\Model\ProductPriceQuery;
|
||||||
use Thelia\Model\CartItem;
|
use Thelia\Model\CartItem;
|
||||||
use Thelia\Model\CartItemQuery;
|
use Thelia\Model\CartItemQuery;
|
||||||
use Thelia\Model\CartQuery;
|
|
||||||
use Thelia\Model\Cart as CartModel;
|
|
||||||
use Thelia\Model\ConfigQuery;
|
use Thelia\Model\ConfigQuery;
|
||||||
use Thelia\Model\Customer;
|
|
||||||
use Thelia\Action\Exception\FormValidationException;
|
use Thelia\Action\Exception\FormValidationException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Class Cart where all actions are manage like adding, modifying or delete items.
|
* Class Cart where all actions are manage like adding, modifying or delete items.
|
||||||
@@ -75,12 +68,12 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
|||||||
*/
|
*/
|
||||||
public function addArticle(ActionEvent $event)
|
public function addArticle(ActionEvent $event)
|
||||||
{
|
{
|
||||||
$request = $event->getRequest();
|
$request = $event->getRequest();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$cartAdd = $this->getAddCartForm($request);
|
$cartAdd = $this->getAddCartForm($request);
|
||||||
|
|
||||||
$form = $this->validateForm($cartAdd);
|
$form = $this->validateForm($cartAdd);
|
||||||
|
|
||||||
$cart = $this->getCart($request);
|
$cart = $this->getCart($request);
|
||||||
$newness = $form->get("newness")->getData();
|
$newness = $form->get("newness")->getData();
|
||||||
@@ -92,8 +85,7 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
|||||||
|
|
||||||
$cartItem = $this->findItem($cart->getId(), $productId, $productSaleElementsId);
|
$cartItem = $this->findItem($cart->getId(), $productId, $productSaleElementsId);
|
||||||
|
|
||||||
if($cartItem === null || $newness)
|
if ($cartItem === null || $newness) {
|
||||||
{
|
|
||||||
$productPrice = ProductPriceQuery::create()
|
$productPrice = ProductPriceQuery::create()
|
||||||
->filterByProductSaleElementsId($productSaleElementsId)
|
->filterByProductSaleElementsId($productSaleElementsId)
|
||||||
->findOne()
|
->findOne()
|
||||||
@@ -102,19 +94,17 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
|||||||
$this->addItem($cart, $productId, $productSaleElementsId, $quantity, $productPrice);
|
$this->addItem($cart, $productId, $productSaleElementsId, $quantity, $productPrice);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($append && $cartItem !== null) {
|
if ($append && $cartItem !== null) {
|
||||||
$this->updateQuantity($cartItem, $quantity);
|
$this->updateQuantity($cartItem, $quantity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->redirect($cartAdd->getSuccessUrl($request->getUriAddingParameters(array("addCart" => 1))));
|
$this->redirect($cartAdd->getSuccessUrl($request->getUriAddingParameters(array("addCart" => 1))));
|
||||||
} catch (PropelException $e) {
|
} catch (PropelException $e) {
|
||||||
\Thelia\Log\Tlog::getInstance()->error(sprintf("Failed to add item to cart with message : %s", $e->getMessage()));
|
\Thelia\Log\Tlog::getInstance()->error(sprintf("Failed to add item to cart with message : %s", $e->getMessage()));
|
||||||
$message = "Failed to add this article to your cart, please try again";
|
$message = "Failed to add this article to your cart, please try again";
|
||||||
}
|
} catch (FormValidationException $e) {
|
||||||
catch(FormValidationException $e) {
|
|
||||||
|
|
||||||
$message = $e->getMessage();
|
$message = $e->getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
// The form has errors, propagate it.
|
// The form has errors, propagate it.
|
||||||
@@ -170,7 +160,6 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
|||||||
return $cartAdd;
|
return $cartAdd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Delete specify article present into cart
|
* Delete specify article present into cart
|
||||||
@@ -207,7 +196,7 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
|||||||
{
|
{
|
||||||
$request = $event->getRequest();
|
$request = $event->getRequest();
|
||||||
|
|
||||||
if(null !== $cartItemId = $request->get("cartItem") && null !== $quantity = $request->get("quantity")) {
|
if (null !== $cartItemId = $request->get("cartItem") && null !== $quantity = $request->get("quantity")) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$cart = $this->getCart($request);
|
$cart = $this->getCart($request);
|
||||||
@@ -217,7 +206,7 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
|||||||
->filterById($cartItemId)
|
->filterById($cartItemId)
|
||||||
->findOne();
|
->findOne();
|
||||||
|
|
||||||
if($cartItem) {
|
if ($cartItem) {
|
||||||
$this->updateQuantity($cartItem, $quantity);
|
$this->updateQuantity($cartItem, $quantity);
|
||||||
}
|
}
|
||||||
} catch (PropelException $e) {
|
} catch (PropelException $e) {
|
||||||
@@ -256,5 +245,4 @@ class Cart extends BaseAction implements EventSubscriberInterface
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user