Jump to content

"Print Invoice" renders Logged in users address rather than customers address


alexm
 Share

Recommended Posts

Ok. So as the comments in the hook example explain, there needs to be logic added to identify the logged in user. I'm thinking the best way to identify the customer details is to add a new role for administrators of the shop and then use a condition to check if a user has said role. If they do, don't auto-populate, as this hook overrides more PadloperProcessOrder::getOrderCustomer and this is used for more than the checkout customer details form.

  • Like 1
Link to comment
Share on other sites

4 hours ago, alexm said:

Ok. So as the comments in the hook example explain, there needs to be logic added to identify the logged in user. I'm thinking the best way to identify the customer details is to add a new role for administrators of the shop and then use a condition to check if a user has said role. If they do, don't auto-populate, as this hook overrides more PadloperProcessOrder::getOrderCustomer and this is used for more than the checkout customer details form.

Great catch! I need to update the demo with this info, at least the description bit, if I cannot find a better hook. Thanks!

Link to comment
Share on other sites

I've simply wrapped the code in the function with:

if (!user()->hasRole('shop')) {
	// Your code from github example here
}

And created a new role assigned to administrators of the shop. That's simple enough I'd say and if an admin wants to test the frontend form auto fill, they can simply deselect the role "shop" for testing. I'm happy with that at least unless, as you say, there is a better hook.

Link to comment
Share on other sites

Even better than the above... just check:

if (wire('page')->template->name != 'admin')

This way, if a logged in admin user is on an admin page the correct customer details will be rendered rather than theirs, but on the front end it will still fill out the admin users details if doing checkout testing.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...