Drupal Commerce: Edit form for commerce_line_items to change order positions after checkout

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:

  1. Just download and enable it as every other module.
  2. Then go to your order fields configuration (admin/commerce/config/order/fields).
  3. Edit your line item field in the order entity (admin/commerce/config/order/fields/commerce_line_items)
  4. Change the widget type to "Inline entity form - multiple values" (admin/commerce/config/order/fields/commerce_line_items/widget-type)
  5. Save and check out the order edit of any order (admin/commerce/orders/246/edit)
  6. Now you have **brand new** operation links in each line item line: Edit & Delete
  7. 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 :)

AnhangGröße
drupal_commerce_bestellpositionen_bearbeiten_inline_entity_form.png10.74 KB

Kommentare

Bild des Benutzers bojanz

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 Smile

Bild des Benutzers Julian Pustkuchen

Thanks a lot! I've just

Thanks a lot! I've just updated the description :)

Bild des Benutzers cobenash

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?

Bild des Benutzers Julian Pustkuchen

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?

Bild des Benutzers cobenash

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.

Bild des Benutzers Julian Pustkuchen

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

Bild des Benutzers Albert Albala

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);

Bild des Benutzers Atec Zhou

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!

Bild des Benutzers Julian Pustkuchen

I'm now using the latest

I'm now using the latest version of inline entity form successfully combined with the information above.

Bild des Benutzers Atec Zhou

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?

Bild des Benutzers Atec Zhou

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..

Bild des Benutzers Wyckham Seelig

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.

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt. Wenn Sie ein zulässiges Avatar mit Ihrer E-Mail-Adresse verknüpft haben, wird dieses als Avatar verwendet.

Weitere Informationen über Formatierungsoptionen