Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New feature: Allow admin to create guest orders and reorder as guest #2233

Merged
merged 4 commits into from
Feb 16, 2024

Conversation

justinbeaty
Copy link
Contributor

@justinbeaty justinbeaty commented Jun 18, 2022

Description (*)

One of my store managers mentioned in passing how she got around having to replace an order for a guest checkout. I am not sure why this is not possible in stock Magento. Maybe there is a good reason, but it seems to work just fine.

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes Add re-order button #244

Manual testing scenarios (*)

  1. Place a guest order
  2. Press the newly available "reorder" button in admin
  3. All details show up, and the order seems to be placed fine.

Questions or comments

Does anyone know why Magento has this disabled? I see others on Stackoverflow as well as in the linked issue asking about it, but the stack overflow answer involved changing a block to add the button: https://magento.stackexchange.com/questions/86531/re-order-for-guests-in-magento

I did PR into 20.0 in case it's breaking in any way.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All automated tests passed successfully (all builds are green)
  • Add yourself to contributors list

@github-actions github-actions bot added the Component: Sales Relates to Mage_Sales label Jun 18, 2022
@ADDISON74 ADDISON74 linked an issue Jun 18, 2022 that may be closed by this pull request
@justinbeaty justinbeaty marked this pull request as draft June 18, 2022 22:16
@justinbeaty
Copy link
Contributor Author

I made this PR too early, I do see some issues.

On the second order, customer name is "Guest" and customer group ID is default customer group, not "NOT LOGGED IN".

I think this is because there's a default customer object attached, and for example that sets the customer group to the default from config.

I will investigate this more and push changes if possible.

@ADDISON74
Copy link
Contributor

I would first evaluate whether this feature is useful and how often it is used.

On the customer's side if he has an account then he can place any past order that he can edit in the shopping cart. As a store I would encourage guest buyers to set up accounts and present the reasons maybe give bonuses.

On the administrator side we can have several situations. You are asked by a guest customer to place an order from the past and this button is useful. You look for the order and place it again. I have never personally encountered this situation. Secondly, I do not recommend this way to be done by the administrator in stores where it is necessary for that customer to agree to the terms and conditions, but also to the processing of personal data.

We can also have the situation described by you but here it is either a request of editing a current open order, or of doubling the existing one with cancellation. Magento did not allow the editing of orders and I consider this a lack as long as you have the customer's consent to do some actions when you do not have the product, quantity or assortment available in stock.

If it is up to me I would implement an option in the store configuration let's say Orders section so that this Reorder button appears or not depending on what the administrator decides. E.g. only for registered customer, only for Guest, for both or not at all. I have this approach because there are stores where more users could have access to the Orders section in Backend and the administrator must decide the appearance of the button. The default value I would set it for "Don't show it" because of the reasons related to legal issues.

If what I said above is not wanted or will not be implemented and if this button still appears for the registered customer orders, I don't see any reason why it wouldn't appear for the guests as well.

@justinbeaty
Copy link
Contributor Author

@ADDISON74 The main reason the store manager needs to reorder a guest order is that the carrier has lost the package in transit, or it arrives damages. In that case, the manager would create a new order, change the price to $0 on each product, and submit so it can be fulfilled as normal during order processing.

Right now, they have to open the old order in a separate window and manually copy each part of the billing/shipping address and re-add the items to the quote, which is time consuming and can be error prone.

As for the config, there is already the option in the admin configuration, but I believe this controls the frontend reorder button as well. Turning it off will definitely remove the reorder button in the admin too. That option could be expanded in another PR to include more options. For this PR however, I think it was probably just a bug that reorder didn't work for guest checkout, so the Magento devs just hid the button as a workaround.

@github-actions github-actions bot added Component: Adminhtml Relates to Mage_Adminhtml JavaScript Relates to js/* labels Jun 21, 2022
@justinbeaty
Copy link
Contributor Author

Pushed commit, admin is now able to create a new guest order, as well as reorder a guest order. I have done light testing and it seems to work so far, I will test more thoroughly.

Screenshot of Sales > Orders > Create New Order:

image


There was very clearly support at one time for this feature, as evidenced by snippets of code below in the current code. I do not know at what point the Magento team probably broke the feature and just decided to hide the "Reorder" button on guest orders.

if ($this->getQuote()->getCustomerIsGuest()) {
unset($attributes['group_id']);
}

if (!$order->getCustomerId()) {
$quote->setCustomerIsGuest(true);
}

if ($quote->getCustomerIsGuest()) {
return $this;
}

if ((!$customer->getId() || !$customer->isInStore($this->getSession()->getStore()))
&& !$quote->getCustomerIsGuest()

@justinbeaty justinbeaty changed the title Allow guest reorders Allow admin guest order and reorder Jun 21, 2022
@justinbeaty
Copy link
Contributor Author

I added a couple of comments on parts of the PR to explain what is happening to make the changes more clear.

@ADDISON74
Copy link
Contributor

I appreciate your effort. Do you have a screenshot of the buttons in the Sales > Orders section?

@justinbeaty
Copy link
Contributor Author

@ADDISON74

Sales > Orders (Nothing changed)

image

Sales > Orders > Create New Order (Added "Create Guest Order" button)

image

Order View (Added "Reorder" button for guest order)

image

@@ -1490,7 +1493,7 @@ public function _prepareCustomer()
$this->_getCustomerForm()
->setEntity($customer)
->resetEntityData();
} else {
} elseif ($customer->getGroupId() !== Mage_Customer_Model_Group::NOT_LOGGED_IN_ID) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could also check !$quote->getCustomerIsGuest() instead of checking $customer->getGroupId().

I chose the latter because the if was also checking the $customer object, but the former is maybe better since it's the same as the conditional I removed at the top of the method. I may push this as a change.

Comment on lines +81 to 84
// if quote is guest, unset customer_group_id
if ($this->getQuote()->getCustomerIsGuest()) {
unset($attributes['group_id']);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment should read:

// if quote is guest, unset group_id dropdown

As it removes the customer group dropdown on the order create screen if we're creating a guest order. I will change and push.

app/code/core/Mage/Sales/Model/Order.php Outdated Show resolved Hide resolved
@fballiano fballiano changed the base branch from 20.0 to main April 4, 2023 17:33
@@ -48,12 +48,23 @@ public function getHeaderText()

public function getButtonsHtml()
{
$html = '';

$addButtonData = array(
'label' => Mage::helper('sales')->__('Create New Customer'),
'onclick' => 'order.setCustomerId(false)',
'class' => 'add',
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if it's not part of the change wouldn't it be better to be here "Create Customer Order"? In doesn't matter if is a New Customer or a Registered one. At least we keep two buttons with a clear message:

[Create Customer Order] [Create Guest Order]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ADDISON74 the first button really creates a new customer so I think it can be left as it is

@ADDISON74 ADDISON74 self-assigned this Jul 14, 2023
@empiricompany
Copy link
Contributor

I just found this PR now. It's a useful and also non-intrusive feature.
I tested it and it works correctly on 20.0.14

@sreichel
Copy link
Contributor

Makes no sense to me to have reoders for guests. Then it needs no guest account. Same for admin created orders.

@justinbeaty
Copy link
Contributor Author

@sreichel how about if the order arrived damaged and we need to send a new one. It’s tedious to manually copy every field, especially address.

I will see if I can rebase today.

@empiricompany
Copy link
Contributor

Makes no sense to me to have reoders for guests. Then it needs no guest account. Same for admin created orders.

It would be useful to us in some cases where the customer needs to create orders on the fly, for example at expos events.

@sreichel
Copy link
Contributor

Of course it can be useful in some cases, but is it something that is used by many users?

Im not an expert, but does it not violate GDPR/DSVGO?

Data from guest orders is not meant to be for operational processes. (???)

(Creating guest orders from backend ... why?)

@fballiano
Copy link
Contributor

I agree with this PR and AFAIK it doesn't create problems with GDPR, but it has conflicts and notes to be addressed.

@sreichel
Copy link
Contributor

sreichel commented Dec 11, 2023

Guest orders are for "anonymized" data. Of course they are in your DB, but only for legal/financial purposes.

For backend orders you have a phone call, an email, ... why to create a guest order? (Also from sellers view?!?)

Imho it better to an extension.

@fballiano
Copy link
Contributor

I still think it's useful when somebody created a guest order from the frontend and needs a reorder or when customer-service has to create a one-stop order for somebody.

@justinbeaty
Copy link
Contributor Author

I think simple the fact that it seems to have been supported in core at one point but disabled (probably due to some bug and they were lazy) is enough to warrant this PR: #2233 (comment)

@github-actions github-actions bot removed the Component: Sales Relates to Mage_Sales label Feb 14, 2024
Copy link
Contributor

@fballiano fballiano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested, it works fine for me.

without this PR I can reorder a guest order but then the duplicated order has the wrong customer_group

with this PR the customer_group is correct

@fballiano fballiano marked this pull request as ready for review February 14, 2024 14:55
@fballiano fballiano changed the title Allow admin guest order and reorder New feature: Allow admin to create guest orders and reorder as guest Feb 16, 2024
@fballiano fballiano merged commit d5805b6 into OpenMage:main Feb 16, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Adminhtml Relates to Mage_Adminhtml JavaScript Relates to js/*
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add re-order button
6 participants