{"id":108115,"date":"2018-01-08T15:55:50","date_gmt":"2018-01-08T15:55:50","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=108115"},"modified":"2024-02-22T10:58:48","modified_gmt":"2024-02-22T10:58:48","slug":"magento2-create-customer-quote-add-products-quote","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/magento2-create-customer-quote-add-products-quote\/","title":{"rendered":"Magento2 Create Customer Checkout Quote and Add Products to that Quote"},"content":{"rendered":"\n<p>Here we will learn, how in Magento2 Create Customer Checkout Quote and Add Products to that Quote.<\/p>\n\n\n\n<p>I have created a demo class here:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Webkul\\Test\\Model;\n\nclass CustomAddToCart\n{\n    public function __construct(\n        \\Magento\\Catalog\\Model\\ProductFactory $productFactory,\n        \\Magento\\Customer\\Model\\Session $customerSession,\n        \\Magento\\Quote\\Api\\CartManagementInterface $quoteManagement,\n        \\Magento\\Quote\\Api\\CartRepositoryInterface $quoteRepository\n    ) {\n        $this-&gt;productFactory = $productFactory;\n        $this-&gt;quoteManagement = $quoteManagement;\n        $this-&gt;quoteRepository = $quoteRepository;\n        $this-&gt;_customerSession = $customerSession;\n    }\n\n    public function quoteAddToCart()\n    {\n        $customerId = $this-&gt;_customerSession-&gt;getCustomerId();\n        \/\/ let&#039;s assume product Id is 50\n        $product = $this-&gt;productFactory-&gt;create()-&gt;load(12490);\n        $params = &#091;\n            &quot;product&quot; =&gt; &quot;12490&quot;,\n            &quot;qty&quot; =&gt; &quot;1&quot;,\n            &quot;options&quot; =&gt; &#091; \/\/if product has options\n                &quot;10&quot; =&gt; &quot;19&quot;\n            ]\n        ];\n        $request = new \\Magento\\Framework\\DataObject();\n        $request-&gt;setData($params);\n        \/\/ here quote is created for customer\n        $quoteId = $this-&gt;quoteManagement-&gt;createEmptyCartForCustomer($customerId);\n        $quote = $this-&gt;quoteRepository-&gt;get($quoteId);\n        $quote-&gt;addProduct($product, $request);\n        $this-&gt;quoteRepository-&gt;save($quote);\n        $quote-&gt;collectTotals();\n    }\n}<\/pre>\n\n\n\n<p>In above snippet you can see i have created the quote by customer id using<br>createEmptyCartForCustomer() method, it will return new Quote Id.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here we will learn, how in Magento2 Create Customer Checkout Quote and Add Products to that Quote. I have created a demo class here: In above snippet you can see i have created the quote by customer id usingcreateEmptyCartForCustomer() method, it will return new Quote Id.<\/p>\n","protected":false},"author":69,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[302],"tags":[6025,6024],"class_list":["post-108115","post","type-post","status-publish","format-standard","hentry","category-magento2","tag-magento2-add-product-to-cart","tag-magento2-quote"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Magento2 Create Customer Checkout Quote Add Products to that Quote<\/title>\n<meta name=\"description\" content=\"Here we will learn, how in Magento 2 Create Customer Checkout Quote and Add Products to that Quote. Magento 2 Add Product to Cart for particular customer.\" \/>\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\/magento2-create-customer-quote-add-products-quote\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Magento2 Create Customer Checkout Quote Add Products to that Quote\" \/>\n<meta property=\"og:description\" content=\"Here we will learn, how in Magento 2 Create Customer Checkout Quote and Add Products to that Quote. Magento 2 Add Product to Cart for particular customer.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/magento2-create-customer-quote-add-products-quote\/\" \/>\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=\"2018-01-08T15:55:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-02-22T10:58:48+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=\"Mahesh Singh\" \/>\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=\"Mahesh Singh\" \/>\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\/magento2-create-customer-quote-add-products-quote\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento2-create-customer-quote-add-products-quote\/\"},\"author\":{\"name\":\"Mahesh Singh\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/53d3b977a0ab5adcf32aef9f97e595bd\"},\"headline\":\"Magento2 Create Customer Checkout Quote and Add Products to that Quote\",\"datePublished\":\"2018-01-08T15:55:50+00:00\",\"dateModified\":\"2024-02-22T10:58:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento2-create-customer-quote-add-products-quote\/\"},\"wordCount\":57,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"keywords\":[\"Magento2 Add Product to Cart\",\"Magento2 Quote\"],\"articleSection\":[\"Magento2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/magento2-create-customer-quote-add-products-quote\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/magento2-create-customer-quote-add-products-quote\/\",\"url\":\"https:\/\/webkul.com\/blog\/magento2-create-customer-quote-add-products-quote\/\",\"name\":\"Magento2 Create Customer Checkout Quote Add Products to that Quote\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"datePublished\":\"2018-01-08T15:55:50+00:00\",\"dateModified\":\"2024-02-22T10:58:48+00:00\",\"description\":\"Here we will learn, how in Magento 2 Create Customer Checkout Quote and Add Products to that Quote. Magento 2 Add Product to Cart for particular customer.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento2-create-customer-quote-add-products-quote\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/magento2-create-customer-quote-add-products-quote\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/magento2-create-customer-quote-add-products-quote\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Magento2 Create Customer Checkout Quote and Add Products to that Quote\"}]},{\"@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\/53d3b977a0ab5adcf32aef9f97e595bd\",\"name\":\"Mahesh Singh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f4c013ebf7008223382b8a49203e6d354677e8baff0eca373e6e4266efa762da?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\/f4c013ebf7008223382b8a49203e6d354677e8baff0eca373e6e4266efa762da?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Mahesh Singh\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/mahesh721\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Magento2 Create Customer Checkout Quote Add Products to that Quote","description":"Here we will learn, how in Magento 2 Create Customer Checkout Quote and Add Products to that Quote. Magento 2 Add Product to Cart for particular customer.","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\/magento2-create-customer-quote-add-products-quote\/","og_locale":"en_US","og_type":"article","og_title":"Magento2 Create Customer Checkout Quote Add Products to that Quote","og_description":"Here we will learn, how in Magento 2 Create Customer Checkout Quote and Add Products to that Quote. Magento 2 Add Product to Cart for particular customer.","og_url":"https:\/\/webkul.com\/blog\/magento2-create-customer-quote-add-products-quote\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2018-01-08T15:55:50+00:00","article_modified_time":"2024-02-22T10:58:48+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":"Mahesh Singh","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Mahesh Singh","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/magento2-create-customer-quote-add-products-quote\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/magento2-create-customer-quote-add-products-quote\/"},"author":{"name":"Mahesh Singh","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/53d3b977a0ab5adcf32aef9f97e595bd"},"headline":"Magento2 Create Customer Checkout Quote and Add Products to that Quote","datePublished":"2018-01-08T15:55:50+00:00","dateModified":"2024-02-22T10:58:48+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/magento2-create-customer-quote-add-products-quote\/"},"wordCount":57,"commentCount":2,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"keywords":["Magento2 Add Product to Cart","Magento2 Quote"],"articleSection":["Magento2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/magento2-create-customer-quote-add-products-quote\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/magento2-create-customer-quote-add-products-quote\/","url":"https:\/\/webkul.com\/blog\/magento2-create-customer-quote-add-products-quote\/","name":"Magento2 Create Customer Checkout Quote Add Products to that Quote","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"datePublished":"2018-01-08T15:55:50+00:00","dateModified":"2024-02-22T10:58:48+00:00","description":"Here we will learn, how in Magento 2 Create Customer Checkout Quote and Add Products to that Quote. Magento 2 Add Product to Cart for particular customer.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/magento2-create-customer-quote-add-products-quote\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/magento2-create-customer-quote-add-products-quote\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/magento2-create-customer-quote-add-products-quote\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Magento2 Create Customer Checkout Quote and Add Products to that Quote"}]},{"@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\/53d3b977a0ab5adcf32aef9f97e595bd","name":"Mahesh Singh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/f4c013ebf7008223382b8a49203e6d354677e8baff0eca373e6e4266efa762da?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\/f4c013ebf7008223382b8a49203e6d354677e8baff0eca373e6e4266efa762da?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Mahesh Singh"},"url":"https:\/\/webkul.com\/blog\/author\/mahesh721\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/108115","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\/69"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=108115"}],"version-history":[{"count":4,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/108115\/revisions"}],"predecessor-version":[{"id":423821,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/108115\/revisions\/423821"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=108115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=108115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=108115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}