{"id":162,"date":"2011-05-02T21:22:58","date_gmt":"2011-05-02T19:22:58","guid":{"rendered":"https:\/\/www.coderblog.de\/?p=162"},"modified":"2012-03-11T17:39:24","modified_gmt":"2012-03-11T16:39:24","slug":"magento-programmatically-create-order","status":"publish","type":"post","link":"https:\/\/www.coderblog.de\/magento-programmatically-create-order\/","title":{"rendered":"Magento Programmatically Create Order"},"content":{"rendered":"<p>I just had to massively rework an interface to another shopping site for a customer. Therefore, I had to programmatically create orders in Magento, which is really an awful challenge. A pretty nice help for this was the code of <a href=\"http:\/\/www.netzarbeiter.com\/\" target=\"_blank\">Vinai Kopp<\/a>, published under <a href=\"http:\/\/pastebin.com\/8cft4d8v\" target=\"_blank\">Pastebin<\/a>.<\/p>\n<p>A little extension for Vinai&#8217;s code: If you already have a customer object <code>$customer<\/code> and want to use the default billing and shipping address, you can set it like that (compare with line 42\/43 of Vinai&#8217;s code):<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">$quote-&gt;getBillingAddress()-&gt;importCustomerAddress($customer-&gt;getPrimaryBillingAddress());\r\n$quote-&gt;getShippingAddress()-&gt;importCustomerAddress($customer-&gt;getPrimaryShippingAddress());<\/pre>\n<p>Hope this helps someone \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I just had to massively rework an interface to another shopping site for a customer. Therefore, I had to programmatically create orders in Magento, which is really an awful challenge. A pretty nice help for this was the code of Vinai Kopp, published under Pastebin. A little extension for Vinai&#8217;s code: If you already have &hellip; <a href=\"https:\/\/www.coderblog.de\/magento-programmatically-create-order\/\" class=\"more-link\"><span class=\"screen-reader-text\">Magento Programmatically Create Order<\/span> weiterlesen<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","footnotes":""},"categories":[3,4],"tags":[],"class_list":["post-162","post","type-post","status-publish","format-standard","hentry","category-magento","category-php"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Magento Programmatically Create Order - Coderblog<\/title>\n<meta name=\"description\" content=\"See how to programmatically create an order in Magento based on the code of Vinai Kopp.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.coderblog.de\/magento-programmatically-create-order\/\" \/>\n<meta name=\"twitter:label1\" content=\"Verfasst von\" \/>\n\t<meta name=\"twitter:data1\" content=\"Simon Sprankel\" \/>\n\t<meta name=\"twitter:label2\" content=\"Gesch\u00e4tzte Lesezeit\" \/>\n\t<meta name=\"twitter:data2\" content=\"1\u00a0Minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.coderblog.de\\\/magento-programmatically-create-order\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.coderblog.de\\\/magento-programmatically-create-order\\\/\"},\"author\":{\"name\":\"Simon Sprankel\",\"@id\":\"https:\\\/\\\/www.coderblog.de\\\/#\\\/schema\\\/person\\\/036aefb13f85a268e6b466d9678871a9\"},\"headline\":\"Magento Programmatically Create Order\",\"datePublished\":\"2011-05-02T19:22:58+00:00\",\"dateModified\":\"2012-03-11T16:39:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.coderblog.de\\\/magento-programmatically-create-order\\\/\"},\"wordCount\":111,\"commentCount\":1,\"articleSection\":[\"Magento\",\"PHP\"],\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.coderblog.de\\\/magento-programmatically-create-order\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.coderblog.de\\\/magento-programmatically-create-order\\\/\",\"url\":\"https:\\\/\\\/www.coderblog.de\\\/magento-programmatically-create-order\\\/\",\"name\":\"Magento Programmatically Create Order - Coderblog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.coderblog.de\\\/#website\"},\"datePublished\":\"2011-05-02T19:22:58+00:00\",\"dateModified\":\"2012-03-11T16:39:24+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.coderblog.de\\\/#\\\/schema\\\/person\\\/036aefb13f85a268e6b466d9678871a9\"},\"description\":\"See how to programmatically create an order in Magento based on the code of Vinai Kopp.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.coderblog.de\\\/magento-programmatically-create-order\\\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.coderblog.de\\\/magento-programmatically-create-order\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.coderblog.de\\\/magento-programmatically-create-order\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Startseite\",\"item\":\"https:\\\/\\\/www.coderblog.de\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Magento Programmatically Create Order\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.coderblog.de\\\/#website\",\"url\":\"https:\\\/\\\/www.coderblog.de\\\/\",\"name\":\"Coderblog\",\"description\":\"Der Blog zweier Programmierer\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.coderblog.de\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"de\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.coderblog.de\\\/#\\\/schema\\\/person\\\/036aefb13f85a268e6b466d9678871a9\",\"name\":\"Simon Sprankel\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4a6e59419e890ac72c27989555df0cc99bba2874551bdfef2c6cb16e1e511f8d?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4a6e59419e890ac72c27989555df0cc99bba2874551bdfef2c6cb16e1e511f8d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4a6e59419e890ac72c27989555df0cc99bba2874551bdfef2c6cb16e1e511f8d?s=96&d=mm&r=g\",\"caption\":\"Simon Sprankel\"},\"sameAs\":[\"https:\\\/\\\/www.coderblog.de\"],\"url\":\"https:\\\/\\\/www.coderblog.de\\\/author\\\/simon\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Magento Programmatically Create Order - Coderblog","description":"See how to programmatically create an order in Magento based on the code of Vinai Kopp.","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:\/\/www.coderblog.de\/magento-programmatically-create-order\/","twitter_misc":{"Verfasst von":"Simon Sprankel","Gesch\u00e4tzte Lesezeit":"1\u00a0Minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.coderblog.de\/magento-programmatically-create-order\/#article","isPartOf":{"@id":"https:\/\/www.coderblog.de\/magento-programmatically-create-order\/"},"author":{"name":"Simon Sprankel","@id":"https:\/\/www.coderblog.de\/#\/schema\/person\/036aefb13f85a268e6b466d9678871a9"},"headline":"Magento Programmatically Create Order","datePublished":"2011-05-02T19:22:58+00:00","dateModified":"2012-03-11T16:39:24+00:00","mainEntityOfPage":{"@id":"https:\/\/www.coderblog.de\/magento-programmatically-create-order\/"},"wordCount":111,"commentCount":1,"articleSection":["Magento","PHP"],"inLanguage":"de","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.coderblog.de\/magento-programmatically-create-order\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.coderblog.de\/magento-programmatically-create-order\/","url":"https:\/\/www.coderblog.de\/magento-programmatically-create-order\/","name":"Magento Programmatically Create Order - Coderblog","isPartOf":{"@id":"https:\/\/www.coderblog.de\/#website"},"datePublished":"2011-05-02T19:22:58+00:00","dateModified":"2012-03-11T16:39:24+00:00","author":{"@id":"https:\/\/www.coderblog.de\/#\/schema\/person\/036aefb13f85a268e6b466d9678871a9"},"description":"See how to programmatically create an order in Magento based on the code of Vinai Kopp.","breadcrumb":{"@id":"https:\/\/www.coderblog.de\/magento-programmatically-create-order\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.coderblog.de\/magento-programmatically-create-order\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.coderblog.de\/magento-programmatically-create-order\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Startseite","item":"https:\/\/www.coderblog.de\/"},{"@type":"ListItem","position":2,"name":"Magento Programmatically Create Order"}]},{"@type":"WebSite","@id":"https:\/\/www.coderblog.de\/#website","url":"https:\/\/www.coderblog.de\/","name":"Coderblog","description":"Der Blog zweier Programmierer","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.coderblog.de\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"de"},{"@type":"Person","@id":"https:\/\/www.coderblog.de\/#\/schema\/person\/036aefb13f85a268e6b466d9678871a9","name":"Simon Sprankel","image":{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/secure.gravatar.com\/avatar\/4a6e59419e890ac72c27989555df0cc99bba2874551bdfef2c6cb16e1e511f8d?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4a6e59419e890ac72c27989555df0cc99bba2874551bdfef2c6cb16e1e511f8d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4a6e59419e890ac72c27989555df0cc99bba2874551bdfef2c6cb16e1e511f8d?s=96&d=mm&r=g","caption":"Simon Sprankel"},"sameAs":["https:\/\/www.coderblog.de"],"url":"https:\/\/www.coderblog.de\/author\/simon\/"}]}},"_links":{"self":[{"href":"https:\/\/www.coderblog.de\/wp-json\/wp\/v2\/posts\/162","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.coderblog.de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.coderblog.de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.coderblog.de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.coderblog.de\/wp-json\/wp\/v2\/comments?post=162"}],"version-history":[{"count":10,"href":"https:\/\/www.coderblog.de\/wp-json\/wp\/v2\/posts\/162\/revisions"}],"predecessor-version":[{"id":333,"href":"https:\/\/www.coderblog.de\/wp-json\/wp\/v2\/posts\/162\/revisions\/333"}],"wp:attachment":[{"href":"https:\/\/www.coderblog.de\/wp-json\/wp\/v2\/media?parent=162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.coderblog.de\/wp-json\/wp\/v2\/categories?post=162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.coderblog.de\/wp-json\/wp\/v2\/tags?post=162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}