Hi sorry not a dev but I think it would be nice if an 'admin' user could:

1 - Select any profile instead of the one used previously
2 - Use a field with search function instead of dropdown

The idea is the cases in which an old customer call via phone to order customer service. The person on the line should be able place the order for him.

Maybe is completely stupid, but I do not think would be much work to create it.

Thanks
Francesco

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bojanz’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev

Moving to 7.x-2.x
This is not on my roadmap. Patches welcome.

drvdt’s picture

+1

drvdt’s picture

Any solution?

gantenx’s picture

subscribing

smaz’s picture

Assigned: Unassigned » smaz
Status: Active » Needs review
FileSize
4.52 KB

Hi there,

We needed this functionality for a company project, so I've created a patch:

  • Added a new permission 'use any address', which allows users to select a user & use one of their saved addresses
  • For those with permission, added a user lookup field to the billing settings screen. Once a user is chosen, the address dropdown is shown with their addresses.

Please note that in order to use the ajax user lookup field, a user will also need the 'administer users' permission. It also will not raise the order in the selected users name - I think that's out of scope for this module.

Testing & feedback welcome!

vasike’s picture

i re-worked the previous patch:
- move the altering code to helper function so it could be used in other cases (#1717234: As an administrator adding a shipping address to an order, I want the ability to search for existing accounts / addresses)
- use existing "administer commerce_customer_profile entities" permission instead of having new permission (ex. 'use any address').
- Order edit form implementation started - #1717234: As an administrator adding a shipping address to an order, I want the ability to search for existing accounts / addresses

I think it requires at least some testing. thank you

Issues:
- Order edit form : i have no success to populate the profile form with data from selected one.
- probably others from tests

stewart.adam’s picture

Status: Needs review » Needs work

I've just tested this and can confirm that the user search and address book functionality works very well. With address population, this would be perfect for setting up customer orders from the admin interface.

bendiy’s picture

Assigned: smaz » Unassigned
Status: Needs work » Needs review
FileSize
15.49 KB

The patch in #6 works for me. I did get an error for a basic user because global $user wasn't included in commerce_addressbook_profile_field_form_alter(). I've attached a patch that fixes this.

I think this is good as is, but I'd like to see some support for someone between an admin and a basic user to do this. Like a Sales Rep. The 'administer commerce_customer_profile entities' permission may be a little to open for that type of user. I may need to add in support for some new hooks to work in my use case. I'll keep kicking the tires on this patch and see if there's other changes that need to be made.

dobe’s picture

Issue summary: View changes

I have applied patch in #8 however when I choose the address it does not populate the fields below the selection therefore it never gets saved. I am looking into it at this point.

I have been digging in this for a bit. I cannot seem to find where the issue is. When I choose an address on the checkout form all works fine for both being logged in as user 1 as well as getting the current user's address.

The functionality fails without error though on the "admin/commerce/orders/add" page.

-Jesse

Ramirez’s picture

Experiencing exactly as #9

tonylegrone’s picture

I'm finding that #9 creates empty profiles every time I try to select an existing one :(

dobe’s picture

Ok I have managed to fix the issue I have experienced please test and confirm. I have just added to #8's patch.

-Jesse

dobe’s picture

dobe’s picture

Woops This one is better. Accidentally forgot one thing.

xurizaemon’s picture

xurizaemon’s picture

As above, but fixes "Unsupported operand types in commerce_addressbook.module on line 306", which I was seeing as authenticated user with limited role.

If $form_addressbook never gets set then commerce_addressbook_profile_field_form_alter() returns the uninitialized variable, which can't be += to an array in commerce_addressbook_form_alter().

sin’s picture

Hi!

I tried 16 but it is not working and I also got error #2309625: Undefined index: #field_name.

Here is fixed variant based on 16. The form structure is different in my case and I fixed form keys in commerce_addressbook_profile_addressbook_user_validate() and commerce_addressbook_profile_field_form_alter().

It is still not working on order admin add/edit page, works for regular cart checkout only. The admin form structure is different, all $form_state['values'][$profile_element][..] fields are $form_state['values'][...] fields now, so all profiles have their fields mixed. I'm unsure why it is so and what to do next.

b_otho’s picture

I managed to get it to work in the admin interface with #14.

millenniumtree’s picture

Re-rolled #14 with some if()s around the commerce_customer_profile_load_multiple() calls.
Our site has a TON of anonymous customer profiles, so if $account->uid or $user->uid are 0, it crushes the server.

xurizaemon’s picture

Is it others expectation that this patch should leave the order belonging to the account which owns the selected address, or belonging to the admin which created it and with the address profile populated with the chosen details?

I think the former makes more sense. Basically, Masquerade for checkout.

WillsCreative’s picture

I've applied #19 and it works perfect when admins create manual orders, however now when customers that don't have anything in their address book try to goto the checkout page, they get a blank white screen. The error log shows this:

Notice: Undefined variable: form_addressbook in commerce_addressbook_profile_field_form_alter() (line 677 of ... commerce_addressbook.module

mglaman’s picture

Status: Needs review » Needs work

Based on comment from #2309625: Undefined index: #field_name marking this as needs work. Also comment from #21.

xurizaemon’s picture

The #field_name property is only set in commerce_addressbook_form_alter() when on form commerce_order_ui_order_form, so this triggers a warning on form commerce_checkout_form_checkout from commerce_addressbook_profile_field_form_alter() which uses that variable.