{"id":174893,"date":"2019-05-16T13:11:10","date_gmt":"2019-05-16T13:11:10","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=174893"},"modified":"2019-05-16T13:41:14","modified_gmt":"2019-05-16T13:41:14","slug":"how-to-check-if-the-cart-is-virtual","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/how-to-check-if-the-cart-is-virtual\/","title":{"rendered":"How to check if the cart is virtual"},"content":{"rendered":"<p>In this blog we will see how to check if the cart is virtual or not in magento 2.<\/p>\n<p>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.<\/p>\n<p>we will use the Quote object containing the quoted data and use isVirtual method of the quote class.<\/p>\n<p>Here i will show you how.<\/p>\n<div>\n<pre class=\"brush:php\">public function isCartVirtual(\\Magento\\Quote\\Api\\Data\\CartInterface $quote)\r\n{\r\n    if ($quote-&gt;getIsVirtual()) {\r\n        $flag = true;\r\n    }\r\n}<\/pre>\n<\/div>\n<div><\/div>\n<div><\/div>\n<div>Now, the return type we are going to get is bool. And perfom our operation using the stuff.<\/div>\n<div>\n<p>Thank you for checking this blog.<\/p>\n<p>Please let me know if you find any issue.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>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 <a href=\"https:\/\/webkul.com\/blog\/how-to-check-if-the-cart-is-virtual\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":263,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,302,211],"tags":[740,674,8544],"class_list":["post-174893","post","type-post","status-publish","format-standard","hentry","category-magento","category-magento2","category-marketplace-2","tag-quote","tag-virtual","tag-virtual-quote"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to check if the cart is virtual - Webkul Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/how-to-check-if-the-cart-is-virtual\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to check if the cart is virtual - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"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 [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/how-to-check-if-the-cart-is-virtual\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-05-16T13:11:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-05-16T13:41:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Rajat Verma\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rajat Verma\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-check-if-the-cart-is-virtual\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-check-if-the-cart-is-virtual\/\"},\"author\":{\"name\":\"Rajat Verma\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/6cdb78fdfd18ba990da43f117619a858\"},\"headline\":\"How to check if the cart is virtual\",\"datePublished\":\"2019-05-16T13:11:10+00:00\",\"dateModified\":\"2019-05-16T13:41:14+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-check-if-the-cart-is-virtual\/\"},\"wordCount\":115,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"keywords\":[\"Quote\",\"virtual\",\"virtual quote\"],\"articleSection\":[\"magento\",\"Magento2\",\"Marketplace\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/how-to-check-if-the-cart-is-virtual\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-check-if-the-cart-is-virtual\/\",\"url\":\"https:\/\/webkul.com\/blog\/how-to-check-if-the-cart-is-virtual\/\",\"name\":\"How to check if the cart is virtual - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"datePublished\":\"2019-05-16T13:11:10+00:00\",\"dateModified\":\"2019-05-16T13:41:14+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-check-if-the-cart-is-virtual\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/how-to-check-if-the-cart-is-virtual\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-check-if-the-cart-is-virtual\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to check if the cart is virtual\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/6cdb78fdfd18ba990da43f117619a858\",\"name\":\"Rajat Verma\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ecad6f740eef36b76420bb9efc0e8e5633bf47af4c05127d527800f481098ed9?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ecad6f740eef36b76420bb9efc0e8e5633bf47af4c05127d527800f481098ed9?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Rajat Verma\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/rajat-verma351\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to check if the cart is virtual - Webkul Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/how-to-check-if-the-cart-is-virtual\/","og_locale":"en_US","og_type":"article","og_title":"How to check if the cart is virtual - Webkul Blog","og_description":"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 [...]","og_url":"https:\/\/webkul.com\/blog\/how-to-check-if-the-cart-is-virtual\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2019-05-16T13:11:10+00:00","article_modified_time":"2019-05-16T13:41:14+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-og.png","type":"image\/png"}],"author":"Rajat Verma","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Rajat Verma","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/how-to-check-if-the-cart-is-virtual\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/how-to-check-if-the-cart-is-virtual\/"},"author":{"name":"Rajat Verma","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/6cdb78fdfd18ba990da43f117619a858"},"headline":"How to check if the cart is virtual","datePublished":"2019-05-16T13:11:10+00:00","dateModified":"2019-05-16T13:41:14+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/how-to-check-if-the-cart-is-virtual\/"},"wordCount":115,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"keywords":["Quote","virtual","virtual quote"],"articleSection":["magento","Magento2","Marketplace"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/how-to-check-if-the-cart-is-virtual\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/how-to-check-if-the-cart-is-virtual\/","url":"https:\/\/webkul.com\/blog\/how-to-check-if-the-cart-is-virtual\/","name":"How to check if the cart is virtual - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"datePublished":"2019-05-16T13:11:10+00:00","dateModified":"2019-05-16T13:41:14+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/how-to-check-if-the-cart-is-virtual\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/how-to-check-if-the-cart-is-virtual\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/how-to-check-if-the-cart-is-virtual\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to check if the cart is virtual"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/6cdb78fdfd18ba990da43f117619a858","name":"Rajat Verma","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/ecad6f740eef36b76420bb9efc0e8e5633bf47af4c05127d527800f481098ed9?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ecad6f740eef36b76420bb9efc0e8e5633bf47af4c05127d527800f481098ed9?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Rajat Verma"},"url":"https:\/\/webkul.com\/blog\/author\/rajat-verma351\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/174893","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/263"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=174893"}],"version-history":[{"count":8,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/174893\/revisions"}],"predecessor-version":[{"id":174925,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/174893\/revisions\/174925"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=174893"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=174893"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=174893"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}