Convert guest customer to regular customer on successful order place in magento 2 Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?How to convert a quote to orderDownload link takes guest customers to a loginMagento 2 - Cant place orders after migrationHow we can create an order programmatically using “**paypal_express**” method in Magento 2.1.xAdd Taxvat field to magento 2 checkout pageMagento 2 Save custom customer attribute to customer addresses in checkoutException message: We can't initialize Express Checkout Magento 2.2.5How to update custom shipping address attribute value after order placeMagento 2.2.5: Custom Checkout Place Order ErrorPaypal payment method does not create customer record Magento 2.1
String `!23` is replaced with `docker` in command line
How to find all the available tools in mac terminal?
How do I keep my slimes from escaping their pens?
How can I make names more distinctive without making them longer?
Why are Kinder Surprise Eggs illegal in the USA?
What's the purpose of writing one's academic biography in the third person?
Identifying polygons that intersect with another layer using QGIS?
List of Python versions
Storing hydrofluoric acid before the invention of plastics
How widely used is the term Treppenwitz? Is it something that most Germans know?
What does this icon in iOS Stardew Valley mean?
When a candle burns, why does the top of wick glow if bottom of flame is hottest?
Is it ethical to give a final exam after the professor has quit before teaching the remaining chapters of the course?
51k Euros annually for a family of 4 in Berlin: Is it enough?
Coloring maths inside a tcolorbox
Error "illegal generic type for instanceof" when using local classes
How to call a function with default parameter through a pointer to function that is the return of another function?
Can a non-EU citizen traveling with me come with me through the EU passport line?
Should I use a zero-interest credit card for a large one-time purchase?
What is Arya's weapon design?
English words in a non-english sci-fi novel
Single word antonym of "flightless"
How do pianists reach extremely loud dynamics?
List *all* the tuples!
Convert guest customer to regular customer on successful order place in magento 2
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?How to convert a quote to orderDownload link takes guest customers to a loginMagento 2 - Cant place orders after migrationHow we can create an order programmatically using “**paypal_express**” method in Magento 2.1.xAdd Taxvat field to magento 2 checkout pageMagento 2 Save custom customer attribute to customer addresses in checkoutException message: We can't initialize Express Checkout Magento 2.2.5How to update custom shipping address attribute value after order placeMagento 2.2.5: Custom Checkout Place Order ErrorPaypal payment method does not create customer record Magento 2.1
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm looking for code to convert guest checkout customer to regular customer on successful order placement.
MagentoSalesApiOrderCustomerManagementInterface $orderCustomerService
in this class I have found one method called create that is accepting order id and converting to a customer. But I guess it is not working.
Anyone know the solution?
magento2 customer-account magento-2.1.7 guest-checkout
add a comment |
I'm looking for code to convert guest checkout customer to regular customer on successful order placement.
MagentoSalesApiOrderCustomerManagementInterface $orderCustomerService
in this class I have found one method called create that is accepting order id and converting to a customer. But I guess it is not working.
Anyone know the solution?
magento2 customer-account magento-2.1.7 guest-checkout
add a comment |
I'm looking for code to convert guest checkout customer to regular customer on successful order placement.
MagentoSalesApiOrderCustomerManagementInterface $orderCustomerService
in this class I have found one method called create that is accepting order id and converting to a customer. But I guess it is not working.
Anyone know the solution?
magento2 customer-account magento-2.1.7 guest-checkout
I'm looking for code to convert guest checkout customer to regular customer on successful order placement.
MagentoSalesApiOrderCustomerManagementInterface $orderCustomerService
in this class I have found one method called create that is accepting order id and converting to a customer. But I guess it is not working.
Anyone know the solution?
magento2 customer-account magento-2.1.7 guest-checkout
magento2 customer-account magento-2.1.7 guest-checkout
edited Feb 19 at 9:13
Khushbu
9010
9010
asked Jan 25 '18 at 11:51
chirag dodiachirag dodia
1
1
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
Finally, I got the solution. By defining event checkout_onepage_controller_success_action and write a below code in observer we can convert the guest user to customer
<?php
$orderId = $orderIds[0];
$order = $this->_orderFactory->create()->load($orderId);
/*Convert guest to customer*/
if ($order->getEntityId() && $this->accountManagement->isEmailAvailable($order->getEmailAddress()))
$this->orderCustomerService->create($orderId);
/*END*/
?>
add a comment |
Below are the two extension links which does the same functionality - Second one is available as free package :
Module Pay: https://www.commerceextensions.com/magento-convert-guest-checkout-customers-to-registered-customers-magento-2.html
Free Module on GitHub: https://github.com/magepal/magento2-guest-to-customer
add a comment |
You can use extension :
http://www.mlx-store.com/magento2-extensions/customer-experience/convert-guest-to-user-for-magento-2.html
https://magefan.com/magento2-convert-guest-to-customer
https://bsscommerce.com/magento-2-guest-to-customer-extension.html
Also, you can use code
$collection = $this->filter->getCollection($this->collectionFactory->create());
$collectionSize = $collection->getSize();
$count = 0;
/** @var $order MagentoSalesModelOrder */
foreach ($collection as $order)
$websiteId = $order->getStore()->getWebsiteId();
$storeId = $order->getStore()->getId();
$customerData = $this->objectCopyService->copyFieldsetToTarget(
'order_address',
'to_customer',
$order->getBillingAddress(),
[]
);
$addresses = $order->getAddresses();
foreach ($addresses as $address)
$addressData = $this->objectCopyService->copyFieldsetToTarget(
'order_address',
'to_customer_address',
$address,
[]
);
/** @var MagentoCustomerApiDataAddressInterface $customerAddress */
$customerAddress = $this->addressFactory->create(['data' => $addressData]);
switch ($address->getAddressType())
case QuoteAddress::ADDRESS_TYPE_BILLING:
$customerAddress->setIsDefaultBilling(true);
break;
case QuoteAddress::ADDRESS_TYPE_SHIPPING:
$customerAddress->setIsDefaultShipping(true);
break;
if (is_string($address->getRegion()))
/** @var MagentoCustomerApiDataRegionInterface $region */
$region = $this->regionFactory->create();
$region->setRegion($address->getRegion());
$region->setRegionCode($address->getRegionCode());
$region->setRegionId($address->getRegionId());
$customerAddress->setRegion($region);
$customerData['addresses'][] = $customerAddress;
$account = $this->createUser($customerData, $websiteId, $storeId, (int)$this->getRequest()->getParam('group'), $count);
$order
->setCustomerId($account->getId())
->setData('customer_group_id', $account->getGroupId())
->setData('customer_is_guest', 0)
->setData('customer_firstname', $account->getFirstname())
->setData('customer_lastname', $account->getLastname());
$this->orderRepository->save($order);
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f210997%2fconvert-guest-customer-to-regular-customer-on-successful-order-place-in-magento%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Finally, I got the solution. By defining event checkout_onepage_controller_success_action and write a below code in observer we can convert the guest user to customer
<?php
$orderId = $orderIds[0];
$order = $this->_orderFactory->create()->load($orderId);
/*Convert guest to customer*/
if ($order->getEntityId() && $this->accountManagement->isEmailAvailable($order->getEmailAddress()))
$this->orderCustomerService->create($orderId);
/*END*/
?>
add a comment |
Finally, I got the solution. By defining event checkout_onepage_controller_success_action and write a below code in observer we can convert the guest user to customer
<?php
$orderId = $orderIds[0];
$order = $this->_orderFactory->create()->load($orderId);
/*Convert guest to customer*/
if ($order->getEntityId() && $this->accountManagement->isEmailAvailable($order->getEmailAddress()))
$this->orderCustomerService->create($orderId);
/*END*/
?>
add a comment |
Finally, I got the solution. By defining event checkout_onepage_controller_success_action and write a below code in observer we can convert the guest user to customer
<?php
$orderId = $orderIds[0];
$order = $this->_orderFactory->create()->load($orderId);
/*Convert guest to customer*/
if ($order->getEntityId() && $this->accountManagement->isEmailAvailable($order->getEmailAddress()))
$this->orderCustomerService->create($orderId);
/*END*/
?>
Finally, I got the solution. By defining event checkout_onepage_controller_success_action and write a below code in observer we can convert the guest user to customer
<?php
$orderId = $orderIds[0];
$order = $this->_orderFactory->create()->load($orderId);
/*Convert guest to customer*/
if ($order->getEntityId() && $this->accountManagement->isEmailAvailable($order->getEmailAddress()))
$this->orderCustomerService->create($orderId);
/*END*/
?>
edited yesterday
Marius♦
168k28324692
168k28324692
answered Feb 19 '18 at 4:04
chirag dodiachirag dodia
1
1
add a comment |
add a comment |
Below are the two extension links which does the same functionality - Second one is available as free package :
Module Pay: https://www.commerceextensions.com/magento-convert-guest-checkout-customers-to-registered-customers-magento-2.html
Free Module on GitHub: https://github.com/magepal/magento2-guest-to-customer
add a comment |
Below are the two extension links which does the same functionality - Second one is available as free package :
Module Pay: https://www.commerceextensions.com/magento-convert-guest-checkout-customers-to-registered-customers-magento-2.html
Free Module on GitHub: https://github.com/magepal/magento2-guest-to-customer
add a comment |
Below are the two extension links which does the same functionality - Second one is available as free package :
Module Pay: https://www.commerceextensions.com/magento-convert-guest-checkout-customers-to-registered-customers-magento-2.html
Free Module on GitHub: https://github.com/magepal/magento2-guest-to-customer
Below are the two extension links which does the same functionality - Second one is available as free package :
Module Pay: https://www.commerceextensions.com/magento-convert-guest-checkout-customers-to-registered-customers-magento-2.html
Free Module on GitHub: https://github.com/magepal/magento2-guest-to-customer
edited Jan 25 '18 at 12:06
Manthan Dave
8,00621539
8,00621539
answered Jan 25 '18 at 12:02
Alex ObrejaAlex Obreja
214
214
add a comment |
add a comment |
You can use extension :
http://www.mlx-store.com/magento2-extensions/customer-experience/convert-guest-to-user-for-magento-2.html
https://magefan.com/magento2-convert-guest-to-customer
https://bsscommerce.com/magento-2-guest-to-customer-extension.html
Also, you can use code
$collection = $this->filter->getCollection($this->collectionFactory->create());
$collectionSize = $collection->getSize();
$count = 0;
/** @var $order MagentoSalesModelOrder */
foreach ($collection as $order)
$websiteId = $order->getStore()->getWebsiteId();
$storeId = $order->getStore()->getId();
$customerData = $this->objectCopyService->copyFieldsetToTarget(
'order_address',
'to_customer',
$order->getBillingAddress(),
[]
);
$addresses = $order->getAddresses();
foreach ($addresses as $address)
$addressData = $this->objectCopyService->copyFieldsetToTarget(
'order_address',
'to_customer_address',
$address,
[]
);
/** @var MagentoCustomerApiDataAddressInterface $customerAddress */
$customerAddress = $this->addressFactory->create(['data' => $addressData]);
switch ($address->getAddressType())
case QuoteAddress::ADDRESS_TYPE_BILLING:
$customerAddress->setIsDefaultBilling(true);
break;
case QuoteAddress::ADDRESS_TYPE_SHIPPING:
$customerAddress->setIsDefaultShipping(true);
break;
if (is_string($address->getRegion()))
/** @var MagentoCustomerApiDataRegionInterface $region */
$region = $this->regionFactory->create();
$region->setRegion($address->getRegion());
$region->setRegionCode($address->getRegionCode());
$region->setRegionId($address->getRegionId());
$customerAddress->setRegion($region);
$customerData['addresses'][] = $customerAddress;
$account = $this->createUser($customerData, $websiteId, $storeId, (int)$this->getRequest()->getParam('group'), $count);
$order
->setCustomerId($account->getId())
->setData('customer_group_id', $account->getGroupId())
->setData('customer_is_guest', 0)
->setData('customer_firstname', $account->getFirstname())
->setData('customer_lastname', $account->getLastname());
$this->orderRepository->save($order);
add a comment |
You can use extension :
http://www.mlx-store.com/magento2-extensions/customer-experience/convert-guest-to-user-for-magento-2.html
https://magefan.com/magento2-convert-guest-to-customer
https://bsscommerce.com/magento-2-guest-to-customer-extension.html
Also, you can use code
$collection = $this->filter->getCollection($this->collectionFactory->create());
$collectionSize = $collection->getSize();
$count = 0;
/** @var $order MagentoSalesModelOrder */
foreach ($collection as $order)
$websiteId = $order->getStore()->getWebsiteId();
$storeId = $order->getStore()->getId();
$customerData = $this->objectCopyService->copyFieldsetToTarget(
'order_address',
'to_customer',
$order->getBillingAddress(),
[]
);
$addresses = $order->getAddresses();
foreach ($addresses as $address)
$addressData = $this->objectCopyService->copyFieldsetToTarget(
'order_address',
'to_customer_address',
$address,
[]
);
/** @var MagentoCustomerApiDataAddressInterface $customerAddress */
$customerAddress = $this->addressFactory->create(['data' => $addressData]);
switch ($address->getAddressType())
case QuoteAddress::ADDRESS_TYPE_BILLING:
$customerAddress->setIsDefaultBilling(true);
break;
case QuoteAddress::ADDRESS_TYPE_SHIPPING:
$customerAddress->setIsDefaultShipping(true);
break;
if (is_string($address->getRegion()))
/** @var MagentoCustomerApiDataRegionInterface $region */
$region = $this->regionFactory->create();
$region->setRegion($address->getRegion());
$region->setRegionCode($address->getRegionCode());
$region->setRegionId($address->getRegionId());
$customerAddress->setRegion($region);
$customerData['addresses'][] = $customerAddress;
$account = $this->createUser($customerData, $websiteId, $storeId, (int)$this->getRequest()->getParam('group'), $count);
$order
->setCustomerId($account->getId())
->setData('customer_group_id', $account->getGroupId())
->setData('customer_is_guest', 0)
->setData('customer_firstname', $account->getFirstname())
->setData('customer_lastname', $account->getLastname());
$this->orderRepository->save($order);
add a comment |
You can use extension :
http://www.mlx-store.com/magento2-extensions/customer-experience/convert-guest-to-user-for-magento-2.html
https://magefan.com/magento2-convert-guest-to-customer
https://bsscommerce.com/magento-2-guest-to-customer-extension.html
Also, you can use code
$collection = $this->filter->getCollection($this->collectionFactory->create());
$collectionSize = $collection->getSize();
$count = 0;
/** @var $order MagentoSalesModelOrder */
foreach ($collection as $order)
$websiteId = $order->getStore()->getWebsiteId();
$storeId = $order->getStore()->getId();
$customerData = $this->objectCopyService->copyFieldsetToTarget(
'order_address',
'to_customer',
$order->getBillingAddress(),
[]
);
$addresses = $order->getAddresses();
foreach ($addresses as $address)
$addressData = $this->objectCopyService->copyFieldsetToTarget(
'order_address',
'to_customer_address',
$address,
[]
);
/** @var MagentoCustomerApiDataAddressInterface $customerAddress */
$customerAddress = $this->addressFactory->create(['data' => $addressData]);
switch ($address->getAddressType())
case QuoteAddress::ADDRESS_TYPE_BILLING:
$customerAddress->setIsDefaultBilling(true);
break;
case QuoteAddress::ADDRESS_TYPE_SHIPPING:
$customerAddress->setIsDefaultShipping(true);
break;
if (is_string($address->getRegion()))
/** @var MagentoCustomerApiDataRegionInterface $region */
$region = $this->regionFactory->create();
$region->setRegion($address->getRegion());
$region->setRegionCode($address->getRegionCode());
$region->setRegionId($address->getRegionId());
$customerAddress->setRegion($region);
$customerData['addresses'][] = $customerAddress;
$account = $this->createUser($customerData, $websiteId, $storeId, (int)$this->getRequest()->getParam('group'), $count);
$order
->setCustomerId($account->getId())
->setData('customer_group_id', $account->getGroupId())
->setData('customer_is_guest', 0)
->setData('customer_firstname', $account->getFirstname())
->setData('customer_lastname', $account->getLastname());
$this->orderRepository->save($order);
You can use extension :
http://www.mlx-store.com/magento2-extensions/customer-experience/convert-guest-to-user-for-magento-2.html
https://magefan.com/magento2-convert-guest-to-customer
https://bsscommerce.com/magento-2-guest-to-customer-extension.html
Also, you can use code
$collection = $this->filter->getCollection($this->collectionFactory->create());
$collectionSize = $collection->getSize();
$count = 0;
/** @var $order MagentoSalesModelOrder */
foreach ($collection as $order)
$websiteId = $order->getStore()->getWebsiteId();
$storeId = $order->getStore()->getId();
$customerData = $this->objectCopyService->copyFieldsetToTarget(
'order_address',
'to_customer',
$order->getBillingAddress(),
[]
);
$addresses = $order->getAddresses();
foreach ($addresses as $address)
$addressData = $this->objectCopyService->copyFieldsetToTarget(
'order_address',
'to_customer_address',
$address,
[]
);
/** @var MagentoCustomerApiDataAddressInterface $customerAddress */
$customerAddress = $this->addressFactory->create(['data' => $addressData]);
switch ($address->getAddressType())
case QuoteAddress::ADDRESS_TYPE_BILLING:
$customerAddress->setIsDefaultBilling(true);
break;
case QuoteAddress::ADDRESS_TYPE_SHIPPING:
$customerAddress->setIsDefaultShipping(true);
break;
if (is_string($address->getRegion()))
/** @var MagentoCustomerApiDataRegionInterface $region */
$region = $this->regionFactory->create();
$region->setRegion($address->getRegion());
$region->setRegionCode($address->getRegionCode());
$region->setRegionId($address->getRegionId());
$customerAddress->setRegion($region);
$customerData['addresses'][] = $customerAddress;
$account = $this->createUser($customerData, $websiteId, $storeId, (int)$this->getRequest()->getParam('group'), $count);
$order
->setCustomerId($account->getId())
->setData('customer_group_id', $account->getGroupId())
->setData('customer_is_guest', 0)
->setData('customer_firstname', $account->getFirstname())
->setData('customer_lastname', $account->getLastname());
$this->orderRepository->save($order);
edited Feb 19 at 9:01
Piyush
4,83972054
4,83972054
answered Feb 19 at 8:42
DavidDavid
211
211
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f210997%2fconvert-guest-customer-to-regular-customer-on-successful-order-place-in-magento%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown