public function isVirtual()
    {
        foreach ($this->getCartItems() as $cartItem) {
            if (0 < $cartItem->getProductSaleElements()->getWeight()) {
                return false;
            }

            $product = $cartItem->getProductSaleElements()->getProduct();
            if (!$product->getVirtual()) {
                return false;
            }
        }

        return true;
    }
public function isVirtual()
    {
        foreach ($this->getCartItems() as $cartItem) {
            if (0 < $cartItem->getProductSaleElements()->getWeight()) {
                return false;
            }

            $product = $cartItem->getProductSaleElements()->getProduct();
            if (!$product->getVirtual()) {
                return false;
            }
        }

        return true;
    }
public function isVirtual ( ) { foreach ( $ this -> getCartItems ( ) as $ cartItem ) { if ( 0 < $ cartItem -> getProductSaleElements ( ) -> getWeight ( ) ) { return false ; } $ product = $ cartItem -> getProductSaleElements ( ) -> getProduct ( ) ; if ( ! $ product -> getVirtual ( ) ) { return false ; } } return true ; }
Tell if the cart contains only virtual products

@return bool
Tell if the cart contains only virtual products