Jump to content

Recommended Posts

Posted

I dunno, if it's just me, but print invoice option on order renders address details for the logged in user/admin rather than the customer's information?

Just going to do some digging and see what that's all about

Posted

Ah ha! It's the customGetOrderCustomer() hook from the demo for auto-populating the checkout customer form fields. 

  • Like 1
Posted

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
Posted
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!

Posted

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.

Posted

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

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
  • Recently Browsing   0 members

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