Convert guest customer to regular customer on successful order place in magento 2 Planned maintenance scheduled April 23, 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
What initially awakened the Balrog?
Using audio cues to encourage good posture
How does Python know the values already stored in its memory?
Is there any word for a place full of confusion?
Performance gap between vector<bool> and array
Maximum summed subsequences with non-adjacent items
Trademark violation for app?
How could we fake a moon landing now?
Has negative voting ever been officially implemented in elections, or seriously proposed, or even studied?
How do I find out the mythology and history of my Fortress?
When a candle burns, why does the top of wick glow if bottom of flame is hottest?
If Windows 7 doesn't support WSL, then what does Linux subsystem option mean?
Why do we need to use the builder design pattern when we can do the same thing with setters?
Do wooden building fires get hotter than 600°C?
Why does it sometimes sound good to play a grace note as a lead in to a note in a melody?
Hangman Game with C++
Is CEO the "profession" with the most psychopaths?
Is there a kind of relay that only consumes power when switching?
Why wasn't DOSKEY integrated with COMMAND.COM?
ArcGIS Pro Python arcpy.CreatePersonalGDB_management
What is the topology associated with the algebras for the ultrafilter monad?
Can a new player join a group only when a new campaign starts?
What would you call this weird metallic apparatus that allows you to lift people?
Is it fair for a professor to grade us on the possession of past papers?
Convert guest customer to regular customer on successful order place in magento 2
Planned maintenance scheduled April 23, 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
10011
10011
asked Jan 25 '18 at 11:51
chirag dodiachirag dodia
83931122
83931122
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 Apr 15 at 7:32
Marius♦
168k28324692
168k28324692
answered Feb 19 '18 at 4:04
chirag dodiachirag dodia
83931122
83931122
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,02121539
8,02121539
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,84972054
4,84972054
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