On our Drupal Commerce site, the Admin order-taking edit form (/admin/commerce/orders/*/edit) provides a pop-up menu to add products after you click the Add Line Item button.
However, I seem to recall it used to give us an Autocomplete text field instead. I think we changed this somewhere at some point to pop-up menu, but now really need to change it back, as we have too many products so a pop-up menu is crazy making.
I've tried changing it in manage fields for Product Display node and in Product entity, but that hasn't had an effect on the Admin order edit form.
Is there a way to change this product selector?
Comments
Comment #1
rszrama commentedActually, I don't believe that's ever had autocomplete integration. You probably changed it on your node type by using the "Autocomplete textfield" widget for the product reference field, but here it's still just a lowly select list. This should be upgraded to a feature request.
Comment #2
somatics commentedRyan,
Thanks for the information. I guess I must just be mis-remembering that it had ever been an autocomplete field.
I think it would be really a great idea to make this a feature -- with even 100 hundred products (and we have several hundred), it's unmanageable to scroll through a list (and it irritates impatient customers!).
Do I have to do anything to request this feature, or is your change of the Category of this post sufficient?
Thanks again!
Steve
Comment #3
rszrama commentedMy change will do the trick. I meant to do this long ago, so it's definitely gonna get in. : )
Comment #4
somatics commentedAwesome. Thanks, and as usual keep up the good work!
Comment #5
rszrama commentedTagging.
Comment #6
rfayI think this one might go too many levels deep for me today :-)
Comment #7
paul.linney commentedI had changed this too for a current project, so made a patch that adds the autocomplete. The only thing I don't like is that it dumps the number into the textfield instead of a nice SKU: Name.
regards,
Paul
Comment #8
paul.linney commentedThe actual file this time.
Comment #9
rfayComment #10
rszrama commentedThanks for posting what you had working, Paul. However, I'd like to just copy the code from the Product Reference module, specifically from commerce_product_reference_field_widget_form() and commerce_product_reference_autocomplete_validate() so that there's no need to change the way the autocomplete callback works in the Product module. We should be able to do the exact same thing the autocomplete text field does here, which is use an element validate handler to convert SKUs into product IDs once the form is submitted.
Comment #11
paul.linney commentedThanks Ryan,
Makes sense not to alter the product module, so I had another look at this and copied the validation from the widget. I also added some error messages for empty submissions and attempts on multiple SKUs.
Updated `commerce_product_line_item_add_form` to prevent loading all the products, as autocomplete doesn't need these.
When adding additional line items with the same product id, is there a way to combine them if the exist in the order already or should they stay separate?
Paul
Comment #12
rszrama commentedIt hasn't combined them thus far, and I think I'm happy with that. There's really no reason for it when the quantity update widget is baked right into the form. Will try to give this a review and get it in.
Comment #14
rszrama commentedOk, as it turns out, this was both simpler and a little more complex. It was simpler because this doesn't need any sort of validation based on multiple SKUs like the product reference widget does. It was more complex because the line item manager widget as coded doesn't really support the normal process of validation inside these AJAX calls. It's unfortunate, but the whole system is going to be replaced by an Inline Product Form approach in 2.x. I don't see any reason to make it all work here now when it's going to be rebuilt from scratch next version.
I also had to go through and fix various tests to accommodate the changed form element name and input type.
Commit: http://drupalcode.org/project/commerce.git/commitdiff/1809ec3
Comment #15
paul.linney commentedGood stuff. I'll need to take a look at the Inline Product Form you have been working on and I did notice the test failure issues, just time got the better of me.
Paul
Comment #16
giorgoskthanks for this feature but there are products that have attributes and hence the autocomplete can not accommodate adding attributes (color, size etc)
should I open up a seperate feature request for this ?
IMHO at least there should be a way to disable adding products for the admin or is a simple permission setting ?
the premise is that if eshop products have attributes giving the admin an incomplete way to add products is at the very least confusing
EDIT: forget about this request, I understand that you are going to implement this on 2.x version
WORKAROUND: for now the admins can create orders for themselves and when done change the user of the order.
Comment #17
rszrama commentedYeah, they can assign the order to the user it needs to be for on the initial submit of the order add form. Also, because every variation of products attributes is represented by a separate product w/ a unique SKU, the autocomplete can easily accommodate products with attributes. The form has never actually presented grouped products like the Add to Cart form does, but as you found out about 2.x plans, we hope to fix that. : )