src/Frontend/Modules/Commerce/Ajax/RemoveProductFromCart.php
/**
     * Remove the product in our cart.
     */
Remove the product in our cart.
Remove the product in our cart .
private function removeCartValue(): ?CartValue
    {
        $cartData = $this->getRequest()->request->get('cart');
        if (!is_array($cartData)) {
            return null;
        }
        if (!array_key_exists('value_id', $cartData)) {
            return null;
        }
        $cartValueRepository = $this->getCartValueRepository();
        if (!$cartValue = $cartValueRepository->getByCartAndId($this->cart, $cartData['value_id'])) {
            return null;
        }
        $this->cart->removeValue($cartValue);
        $cartValueRepository->removeByIdAndCart($cartValue->getId(), $this->cart);
        return $cartValue;
    }
private function removeCartValue ( ) : ? CartValue { $ cartData = $ this -> getRequest ( ) -> request -> get ( 'cart' ) ; if ( ! is_array ( $ cartData ) ) { return null ; } if ( ! array_key_exists ( 'value_id' , $ cartData ) ) { return null ; } $ cartValueRepository = $ this -> getCartValueRepository ( ) ; if ( ! $ cartValue = $ cartValueRepository -> getByCartAndId ( $ this -> cart , $ cartData [ 'value_id' ] ) ) { return null ; } $ this -> cart -> removeValue ( $ cartValue ) ; $ cartValueRepository -> removeByIdAndCart ( $ cartValue -> getId ( ) , $ this -> cart ) ; return $ cartValue ; }
Remove the product in our cart.
Remove the product in our cart .
// Retrieve our product // Remove the value