In this blog we will see how to check if the cart is virtual or not in magento 2.
After adding the products to the cart, when ever we need to check if the products added in the cart is virtual without looping over quote item or doing some other stuffs.
we will use the Quote object containing the quoted data and use isVirtual method of the quote class.
Here i will show you how.
public function isCartVirtual(\Magento\Quote\Api\Data\CartInterface $quote) { if ($quote->getIsVirtual()) { $flag = true; } }
Now, the return type we are going to get is bool. And perfom our operation using the stuff.
Thank you for checking this blog.
Please let me know if you find any issue.
Be the first to comment.