Problem/Motivation
Single search field like the product search in POS
Searches, if available:
email
username
phone number
name
address
Shows results in ajax style like the Product widget.
If no user is found, you should be able to quickly create a new customer, with a minimum of an email or phone number ONLY, although if possible allow for other details, although that might make sense in a followup issue.
Proposed resolution
Create customer lookup widget
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #46 | pos_new_customer_widget-2921655-46.patch | 31.5 KB | smccabe |
| #32 | pos_new_customer_widget-2921655-32.patch | 29.44 KB | shabana.navas |
| #31 | pos_new_customer_widget-2921655-31.patch | 18.18 KB | shabana.navas |
| #29 | new_customer_widget.gif | 1.21 MB | shabana.navas |
| #29 | pos_new_customer_widget-2921655-29.patch | 13.97 KB | shabana.navas |
Comments
Comment #2
smccabe commentedThis gif is of the order edit screen, not the POS screen, which should already have the default ability to search and pick users if i recall.
Comment #3
shabana.navas commentedNope, we still don't have a customer lookup for POS.
Comment #4
sorabh.v6Comment #5
sorabh.v6Whenever I remove user from the POS form using remove button, it not only remove the user from the form but from drupal too. Therefore, I suggest we remove this block from the POS form.
Comment #6
sorabh.v6Comment #7
sorabh.v6Hi,
I have removed the customer block and left the customer email textfield as it is. After removing the customer field from form I checked to see the POS order are created successfully and have no problem. I tried to use CustomerFormTrait to create the customer lookup field same ways as used in OrderAddForm. But it is not changing the field by clicking the new user radio button as can be seen in attached gif -
Please review the patch and suggest the next step.
Thanks
Comment #8
heddnThe IS and what is being discussed lower down don't match up. It would help to improve the IS.
Comment #9
smccabe commentedUpdated Issue summary to reflect what we should build here, vs tweaking some existing stuff.
Comment #10
rakesh.gectcrComment #11
rakesh.gectcrComment #12
rakesh.gectcrComment #13
rakesh.gectcrComment #14
jcandan commented@sorabh.v6, your patch in #7 is incomplete. It doesn't contain the changes that would provide the functionality that your gif demonstrates. Could you please recreate the patch and upload it.
Comment #15
sorabh.v6@jcandan Ah! What I wanted to show in that gif is a problem. The customer autocomplete field on the order form works perfectly but when I imported that customer field on POS form, it wasn't working for the new customers. As you can see in the gif, the field doesn't change when I click on the new customer radio button.
Again, sorry for the incomplete information.
Comment #16
rakesh.gectcr@here, Shall we use the search API for making the search possible? While installing drupal commerce using composer, however search api module getting downloaded at the beginning itself, So shall we make use of that ?
Comment #17
smccabe commented@rakesh what we normally do is a simple db query as a default and then search api if available. Lets it have fewer mandatory requirements if people don't want to get complex. Do whichever one you feel like first though, your call.
Comment #18
alexpott@smccabe and @rakesh.gectcr asked me to provide some direction here.
At the moment the customer field is an inline entity form - complex widget. It's not quite configured the way we'd like and it doesn't work for creating users. These feel at bit like bugs in inline_entity_form. I'm going to have a look at that module and see what's going on. It'd be great if we could get most of the functionality required here without having to do a custom widget like we did with products (that needed to be special because of the order -> product -> product_variation relationship). The patch attached configures the field it a way that's a bit more likely. And we also need to not attach the user creating the order because that's not the expected behaviour for Commerce POS.
Comment #19
rakesh.gectcr@alexpott
Yes, there is an an issue reported in IEF module https://www.drupal.org/project/inline_entity_form/issues/2702401#comment-11898337
after applying the above patch I am able to get the form to create new user.
Comment #20
rakesh.gectcrComment #21
rakesh.gectcrComment #22
deepakaryan1988I am also able to open the form and changed few things in the code.
Please let me know if this needs further enhancement.
Comment #24
deepakaryan1988Re uploading the patch after changing in the code.
Comment #25
deepakaryan1988Comment #26
alexpottThe use of CAPITALS here is not correct. The capitals standard is for PHP. For yaml files we use the format written by Symfony's Yaml component as our standard - which is the patch in #18.
So @smccabe we have a choice here. Do we create our own widget for user registration or do we push on #2702401: Add integration for the user entity type and try and get that done for IEF.
Comment #27
alexpottRe-uploading the patch from #18 to make the most recent patch the correct patch.
Comment #28
smccabe commentedBojan is trying to decrease Commerce cores dependency on IEF, since it is a maintenance nightmare. Making it work for all entity types is a constant pain.
We should probably follow suit and do the same, so a custom widget similar to what we did for order items makes the most sense.
Comment #29
shabana.navas commentedA WIP of the new customer widget.
Comment #31
shabana.navas commentedMore changes. Still need to implement look up by customer order billing name, address and phone. And of course TESTS!
Comment #32
shabana.navas commentedReady for review. Tests also included.
Comment #34
shabana.navas commentedPhpcs fixes.
Comment #35
shabana.navas commentedComment #37
shabana.navas commentedFixed code for tests.
Comment #38
alexpottNot used.
Can we convert this into two entity queries - one against users and one against profiles?
I'm not sure that we should link the two widgets like this. Maybe we should make the widgets use something set by PosForm if it is set or add there own if not. This will make the widgets a bit more independent.
Comment #39
sorabh.v6Comment #40
sorabh.v6@alexpott
I tried to convert the query into two entity queries as suggested in point 2, but I need some direction. I can get the user query and profile query using -
But how to apply join on them and how to do the other joins also -
I also need some more information about point 3.
Comment #41
shabana.navas commentedSaurabh, I believe what Alex is recommending is (correct me if I'm wrong Alex) we first do an entity query on the users table, and if we haven't got a user, we then, do an entity query on the profile table. So, you'd do something like this:
As for the comment on
remove that line. I think we should just set a form wrapper in POSForm.php and then, in OrderItemWidget and CustomerWidget, we just make sure that $form has a prefix and suffix and then, use that as the ajax wrapper ID. If it doesn't exist (which it will as we're setting it in POSForm.php, but just to be safe), then, we do our own, $form['#prefix'] = ....
Comment #42
alexpott@shabana.navas++ yep exactly.
Comment #43
shabana.navas commentedGreat, thanks for the confirmation Alex!
Comment #44
sorabh.v6Thanks guys, will post the updated patch soon.
Comment #45
smccabe commentedFlipped the entity_query work to a separate issue, it isn't quite as simple as it seems.
I think the real change here is we should just build in some search_api support for both customers and order_items, as that would allow much better searching that either of these methods.
#2938569: Add Search API Support
Comment #46
smccabe commentedFixed up the form stuff as per Shabana and Alex's recommendations
Comment #48
smccabe commentedComment #49
sorabh.v6