
Drupal Commerce: Edit form for commerce_line_items to change order positions after checkout
One thing I missed within Drupal Commerce's (commerce.module) flexibility was to change line item values in already checked out orders. This is for example important, if you use custom fields in line items and want to change the values on users request (for customizable products for example).
I had to search a bit to find a robust solution, but finally I am very happy with the solution I'm describing in this blog post.
How to make Commerce line items editable?
The solution is quite simple! All you need is the inline_entity_form.module!
[UPDATE] Comment by bojanz: And for the best experience you should be using at least Inline Entity Form 1.5!
Then follow these steps:
- Just download and enable it as every other module.
- Then go to your order fields configuration (admin/commerce/config/order/fields).
- Edit your line item field in the order entity (admin/commerce/config/order/fields/commerce_line_items)
- Change the widget type to "Inline entity form - multiple values" (admin/commerce/config/order/fields/commerce_line_items/widget-type)
- Save and check out the order edit of any order (admin/commerce/orders/246/edit)
- Now you have **brand new** operation links in each line item line: Edit & Delete
- Click it and be happy! You can now change each line item :)
Feel free to leave a comment, if this post was helpful for you!
For paid Drupal CMS development visit us at http://www.DROWL.de :)
Attachment | Size |
---|---|
drupal_commerce_bestellpositionen_bearbeiten_inline_entity_form.png | 10.74 KB |
Julian Pustkuchen, M. Sc. Wirtschaftsinformatik ist passionierter Software- & Webentwickler mit den Schwerpunkten Softwaredesign, Objektorientierung sowie Usability- & Ablaufoptimierung bei webks. Ein weiterer Schwerpunkt ist die Entwicklung im CMS Drupal.
Entwickelt Julian gerade keine Software, fährt er Ski, Mountainbike, spielt Badminton, segelt oder verbringt Zeit mit Freunden.
Dieser Blog dient als sein "öffentlicher Notizblo(ck/g)".
Webbasierte Lösungen? Machen wir!
webks: websolutions kept simple
http://www.webks.de
Dir hat dieser Beitrag viel Zeit und Nerven gespart?
Dann freue ich mich über jede kleine Anerkennung:
Oder du suchst weitere professionelle Unterstützung?
Dann bietet dir unser webks.de Softwareentwickler-Team professionelle Dienstleistungen im Web-Development und der Drupal CMS Entwicklung!
Comments
And for the best experience
And for the best experience you should be using at least Inline Entity Form 1.5 (released today). Has tasty bugfixes for the line item form
Thanks a lot! I've just
Thanks a lot! I've just updated the description :)
Use this module is easy, but
Use this module is easy, but can't change the form table and unit price in the form.
Is there another way?
As I just had to find out it
As I just had to find out it currently does not work with the described solution. After saving a change the line item price and total order amount is reset to zero.
I think it may have to do with the rules based price calculation. Any way out or even same problem in your case?
i used the author's patch in
i used the author's patch in this issue
at druapl-node-2180017
this patch can change the unit price in the inline entity form.
But there's still a little unfriendly place when we add the line item.
The default product price doesn't show.
You can try this patch and find what i am talking about.
Thanks a lot! I've just read
Thanks a lot! I've just read the issue. Here's the full link and I think it still needs some love :)
https://drupal.org/node/2180017
If you want to do this
If you want to do this programmatically for Drupal 7 (for example in an update hook), you can use this code:
$instance = field_info_instance('commerce_order', 'commerce_line_items', 'commerce_order');
$instance['widget'] = array(
'type' => 'inline_entity_form_single',
'module' => 'inline_entity_form',
);
field_update_instance($instance);
Line item custom field value not be saved after update line item
I ran into an issue. Julian, Can you share your experience? Thanks in advance.
Environment: commerce_kickstart-7.x-2.22(With IEF 1.5 and the widget: Inline entity form - Multiple values)
Steps to produce this issue:
1. Add a "field_additional_information" text field on admin/commerce/config/line-items/product/fields, Do not include it on "add to Cart from".
2. Switch widget line item manager into inline entity form - multiple values.
3. Edit order on admin/commerce/orders/%commerce_order/edit, click "Edit" link to edit a line item, "field_additional_information" field is shown, fill something in it.
4. Reopen admin/commerce/orders/%commerce_order/edit page, click "Edit" link again, the value of "field_additional_information" field is not be shown(leave blank). Check database, the value is not be saved.
Any comment or help would be appreciated!
I'm now using the latest
I'm now using the latest version of inline entity form successfully combined with the information above.
Thanks a lot, But which is the last, 7.x-1.x-dev or 7.x-1.5?
Thank you so much for your reply, Julian.
But the latest version you mentioned is 7.x-1.x-dev, not 7.x-1.5, right?
Both 7.x-1.x-dev and 7.x-1.5 do not work for me.
I tried both 7.x-1.x-dev and 7.x-1.5, they do not work for me. I don't know what I miss..
Events fired by Inline Entity Form
I'm wondering if anybody knows what Events the Inline Entity Form fires.
Use case: I am trying to use Rules to change the price of a Line Item if a custom field in the Line Item is set. My Rule works on the Event "Add Item to Cart", but does not fire on any other Event I can find when I'm editing a Line Item from the Inline Entity Form.
hi ll qh
buying cialis online safely
Post new comment