* @param ProductVariant $productVariant
* @param int $quantity
* @return OrderItem
* @throws \AWEcommerceBundle\Exception\OutOfStockException
*/
public function addProductVariantToUser(User $user, ProductVariant $productVariant, $quantity = 1, $customText = null)
{
/** @var Order $order */
$order = $this->getOrCreateCartOrder($user);
$this->eventDispatcher->dispatch(new OrderEvent($order), OrderEvent::POST_CREATED_EVENT);
$this->eventDispatcher->dispatch( new OrderEvent($order), OrderEvent::PRE_UPDATED_EVENT);
int $quantity)
{
$user = $currentUserProvider->get();
try{
$orderManager->addProductVariantToUser($user, $variant, $quantity, $request->get('customText'));
}catch (OutOfStockException $exception) {
return new Response($translator->trans('api.ecommerce.order_item.error.out_of_stock'), Response::HTTP_BAD_REQUEST);
}
return $this->redirectToRoute('aw_ec_cart_index');
$this->dispatcher->dispatch($event, KernelEvents::CONTROLLER_ARGUMENTS);
$controller = $event->getController();
$arguments = $event->getArguments();
// call controller
$response = $controller(...$arguments);
// view
if (!$response instanceof Response) {
$event = new ViewEvent($this, $request, $type, $response);
$this->dispatcher->dispatch($event, KernelEvents::VIEW);
{
$request->headers->set('X-Php-Ob-Level', (string) ob_get_level());
$this->requestStack->push($request);
try {
return $this->handleRaw($request, $type);
} catch (\Exception $e) {
if ($e instanceof RequestExceptionInterface) {
$e = new BadRequestHttpException($e->getMessage(), $e);
}
if (false === $catch) {
No log messages
TypeError |
---|
TypeError: Argument 1 passed to AWEcommerceBundle\Manager\OrderManager::addProductVariantToUser() must be an instance of AWEcommerceBundle\Entity\User, null given, called in /var/www/vendor/simpledot/ecommerce-bundle/AWEcommerceBundle/Controller/Front/OrderController.php on line 70 at vendor/simpledot/ecommerce-bundle/AWEcommerceBundle/Manager/OrderManager.php:193 at AWEcommerceBundle\Manager\OrderManager->addProductVariantToUser() (vendor/simpledot/ecommerce-bundle/AWEcommerceBundle/Controller/Front/OrderController.php:70) at AWEcommerceBundle\Controller\Front\OrderController->initOrderAction() (vendor/symfony/http-kernel/HttpKernel.php:159) at Symfony\Component\HttpKernel\HttpKernel->handleRaw() (vendor/symfony/http-kernel/HttpKernel.php:81) at Symfony\Component\HttpKernel\HttpKernel->handle() (vendor/symfony/http-kernel/Kernel.php:201) at Symfony\Component\HttpKernel\Kernel->handle() (public/index.php:33) |