{"id":543,"date":"2015-01-06T01:05:56","date_gmt":"2015-01-05T19:05:56","guid":{"rendered":"http:\/\/promincproductions.com\/blog?p=543&#038;preview_id=543"},"modified":"2021-10-23T13:57:42","modified_gmt":"2021-10-23T18:57:42","slug":"magento-associate-order-user-account-customer-checked-guest","status":"publish","type":"post","link":"https:\/\/promincproductions.com\/blog\/magento-associate-order-user-account-customer-checked-guest\/","title":{"rendered":"Magento 1: Associate order with user account when customer checked out as guest"},"content":{"rendered":"<p>It&#8217;s going to happen when you run an E-Commerce website &#8211; a user who has an account checkouts while is a guest, contacts you and wants the two to be associated. &nbsp;Yeah, extra work for you!<\/p>\n\n\n\n<p>In Magento, there isn&#8217;t a default feature that allows you to associate these two together. &nbsp;(Bad news, I know). &nbsp;BUT, it can be done. &nbsp;{insert asterisk here}<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/01\/Magento-Associate-Order-to-Customer-Database.jpg\" rel=\"attachment wp-att-589\" data-lasso-id=\"270\" data-rel=\"lightbox-gallery-J2sXxnVc\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"500\" height=\"500\" src=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/01\/Magento-Associate-Order-to-Customer-Database-500x500.jpg\" alt=\"How to associate a customers order to the customers account in Magento\" class=\"wp-image-589\" srcset=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/01\/Magento-Associate-Order-to-Customer-Database-500x500.jpg 500w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/01\/Magento-Associate-Order-to-Customer-Database-150x150.jpg 150w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/01\/Magento-Associate-Order-to-Customer-Database.jpg 600w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><figcaption>How to connect a Magento order to a customer in the database.<br>If a customer checks out while logged in, this happens by default. However, if a customer did not log in when checking out, and later wants the order associated to their account, follow these steps to tie the two together.<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Solution Options<\/h2>\n\n\n\n<p>There are two ways to approach this:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Install an extension<\/li><li>Manually edit the database<\/li><\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Associate Customers Order With Account Via a Magento&nbsp;Extension<\/h2>\n\n\n\n<p>I know extensions are out there for this, but I have not personally used one and thus will not endorse, recommend, or even link one here for you. &nbsp;But a bit of effort should put you in the right direction.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Update January 5th, 2016<\/h3>\n\n\n\n<p>While I stated previously that I didn&#8217;t have an endorsement for a Magento Extension for linking a customer to an order through the Magento Admin, I am now endorsing an extension. &nbsp;I feel confident endorsing it because I wrote it. &nbsp;Yes, it&#8217;s a shameless plug. &nbsp;But it&#8217;s a free extension, so really it&#8217;s ok, right?<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Magento Extension to Link a Customer to a Guest Order<\/h4>\n\n\n\n<p>The PromInc Magento Extension for linking customers and orders is available via Github and will require a manual installation as opposed to using Magento Connect. &nbsp;Feel free to download the code to add to&nbsp;your own Magento install. &nbsp;Installation and usage instructions are also documented on Github.<\/p>\n\n\n\n<p><a class=\"btn btn-danger\" href=\"https:\/\/github.com\/PromInc\/Magento-1.x-Link-Customer-to-Order\" target=\"_blank\" rel=\"noopener\" data-lasso-id=\"271\">Download Magento Link Customer to Order Extension via Github \u2192<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Associate Customers Order With Account Via Database<\/h2>\n\n\n\n<p>What I will share with you however is how to make this correction manually in the database. &nbsp;To do this however, you need database access to your Magento site via either PHP MyAdmin, a 3rd party database tool like MySql Workbench, NovaBench, etc., or command line access.<\/p>\n\n\n\n<p><strong>NOTE<\/strong>: If you were completely lost by that last sentence, I&#8217;m assuming you are not a developer and\/or a database admin, and this is where you would be best to turn and walk away from this post. &nbsp;:) &nbsp;I&#8217;m not trying to be rude but more honest. &nbsp;The setup for those tools requires configuration from your webhost, and the proper knowledge to know how to utilize these tools. &nbsp;Playing in the database isn&#8217;t something a novice should be doing &#8211; you can create a lot of undesirable results in there if you don&#8217;t know what you are doing.<\/p>\n\n\n\n<p>Ok, for those of you that are still reading and understanding, here is the solution you are looking for. &nbsp;I know this solution works for Magento version 1.4.1 and greater.<\/p>\n\n\n\n<p>You will need to know the following information:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>The Customers&#8217; ID (customer_id)\n<ul>\n<li>The easiest way to find the Customer ID&nbsp;is to view&nbsp;the customer in the Magento Admin and look at the URL for that customer&nbsp;in the address bar&nbsp;&#8211; the Customer ID&nbsp;is the number&nbsp;at the end of the URL.<br>https:\/\/www.yoursite.com\/index.php\/guru\/customer\/edit\/id\/<strong><em>200490<\/em><\/strong>\/<\/li>\n<\/ul>\n<\/li><li>The Order ID (entity_id)\n<ul>\n<li><strong>NOTE<\/strong>: This is the Database entity ID, NOT&nbsp;the Order ID that you use on your invoices.<\/li>\n<li>The easiest way to find the Order ID&nbsp;is to open the order in the Magento Admin and look at the URL for that order in the address bar- Order ID it is the number&nbsp;at the end of the URL.<br>https:\/\/www.yoursite.com\/index.php\/guru\/sales_order\/view\/order_id\/<em><strong>291855<\/strong><\/em>\/<\/li>\n<\/ul>\n<\/li><\/ul>\n\n\n\n<p>There are two tables in the Magento Database that need to be updated:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>sales_flat_order<\/li><li>sales_flat_order_grid\n<ul>\n<li><strong>NOTE<\/strong>: I believe this table is only used for the Magento Admin<\/li>\n<\/ul>\n<\/li><\/ul>\n\n\n\n<p>If you are using a GUI based database editing tool like MySQL Workbench, you simply need to edit the Order ID entry in the two tables listed above, setting the customer_id field to the Customer ID found above.<\/p>\n\n\n\n<p>If you prefer to do this via a SQL script, you can use the following two scripts, replacing&nbsp;<em style=\"color: #000000\"><strong>CUSTOMER ID<\/strong><\/em> and&nbsp;<em style=\"color: #000000\"><strong><em><strong>Order<\/strong><\/em><\/strong><\/em><strong><strong> ID<\/strong><\/strong> with the appropriate info found above.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted lang:mysql decode:true\">UPDATE sales_flat_order \n   SET customer_id = CUSTOMER ID, customer_is_guest = 0\nWHERE entity_id = Order ID AND customer_id IS NULL<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted lang:mysql decode:true\">UPDATE sales_flat_order_grid \n    SET customer_id = CUSTOMER ID \nWHERE entity_id = Order ID AND customer_id IS NULL<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted lang:mysql decode:true\">UPDATE sales_flat_order_address \n    SET customer_id = CUSTOMER ID \nWHERE parent_id = Order ID AND customer_id IS NULL<\/pre>","protected":false},"excerpt":{"rendered":"<p>It&#8217;s going to happen when you run an E-Commerce website &#8211; a user who has an account checkouts [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":589,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wprm-recipe-roundup-name":"","wprm-recipe-roundup-description":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[46,5],"tags":[],"class_list":["post-543","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-magento","category-website-development"],"jetpack_featured_media_url":"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2015\/01\/Magento-Associate-Order-to-Customer-Database.jpg","jetpack_shortlink":"https:\/\/wp.me\/p4BbcR-8L","jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts\/543","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/comments?post=543"}],"version-history":[{"count":9,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts\/543\/revisions"}],"predecessor-version":[{"id":2042,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts\/543\/revisions\/2042"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/media\/589"}],"wp:attachment":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/media?parent=543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/categories?post=543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/tags?post=543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}