alexm Posted December 12, 2022 Posted December 12, 2022 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
alexm Posted December 12, 2022 Author Posted December 12, 2022 Ah ha! It's the customGetOrderCustomer() hook from the demo for auto-populating the checkout customer form fields. 1
alexm Posted December 12, 2022 Author Posted December 12, 2022 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. 1
kongondo Posted December 12, 2022 Posted December 12, 2022 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!
alexm Posted December 12, 2022 Author Posted December 12, 2022 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.
alexm Posted December 12, 2022 Author Posted December 12, 2022 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. 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now