There currently isn't a form for adding / editing line items because it's been happening solely through API functions. These include a little bit of hackery to manipulate the field API for things like populating fields on product line items. If there were a form we could begin to take advantage of it at least on the order edit UI to manipulate line items.

Comments

redben’s picture

Would this form persist the changes to line items directly or would it wait until you hit "save" on the order ?

mertskeli’s picture

Line item is everything defined by DC, right? Not only a product, but also discounts, coupons, shipping rates, taxes, etc.? Is it a content regardless of its type?
If yes, it means that any line item creation starts from choosing a Line item type.
Should it be a dropdown dynamic form? I don't know... Maybe just to define types as in Drupal, and then make a form for each of them? It would be easier and drupalish. But imho would be better not to add types to Drupal menu - just leave it in Store menu.

videographics’s picture

Are we still waiting for a way to edit the data in the fields we create for line item types or did I miss something?

jrust’s picture

Just a note from another discussion, #1190654: Add hook that allows line item to be modified by add to cart's form values., it would be helpful if this new form replaced the add to cart form so that other modules could hook into the process and modify the line item data whenever a line item is created, either through the frontend or backend. It means the form would need to accept the settings currently passed by the field formatter for the add to cart form, as well as any additional formatter settings other modules defined. I suppose the best thing would be if there were two formatters, one for an admin Add to Order form and another customer-facing Add to Cart form, both of which could be modified by other modules that implemented hook_field_formatter_view().

rszrama’s picture

Issue tags: -dcsprint3 +rcblocker, +dcsprint7
rszrama’s picture

Issue tags: -rcblocker, -dcsprint7

Hmm, I shouldn't have added rcblocker to this issue. We do need to implement a line item add / edit form, but at this point there's no functionality we need that this would provide. It would just make other code cleaner. That to me isn't enough to hold up a release candidate.

jaymallison’s picture

Isn't this important just solely for the fact that it'll allow editing of fields added to the line item types through the order edit screen?

As it is now, I don't see any use for line item fields unless you add them to the add to cart form. Just because I don't want them on the add to cart form, doesn't mean they aren't useful on the order edit screen.

rszrama’s picture

Yep, that's exactly why it's important. : )

When I made that comment in July, I don't believe I had implemented the ability to expose line item fields through the Add to Cart form. The fact that you can do that now makes this support more important. My goal is to create a contrib based on Commerce IPF that will work for line items for 1.x and make it core for 2.x.

larowlan’s picture

Subscribe.
I have several modules for Ubercart that leveraged hook_add_to_cart_data which rely on this level of functionality in order to be implemented in an elegant manner. I also see that the rooms project had difficulties finding a clean way to store line-item data (stay dates, number of adults/children) and ended up creating a new product entity for every booking. So I think if this was done well it would be awesome (particularly if we were using fields to store the data we needed - hence automatically opening up Rules/Views etc integration).
I'd be willing to work on this if you could point me in the right direction.
My use case is a classifieds site.
I want to associate a line item (of a particular type) with the classified listing (node) so that when the order is complete the node gets published.
As I'll be adding the line-item to the cart during hook_node_insert (of the listing node) I don't think this will be a blocker for me but until I get further into it, I guess I won't know.
Lee

BenStallings’s picture

Status: Active » Closed (duplicate)

Unless I'm mistaken, this issue is now a duplicate of #1211278: Allow commerce_cart_add_to_cart_form() to edit line items.

rszrama’s picture

Status: Closed (duplicate) » Active

Nope, we still need a separate form, so we'll leave this open. Think about the back end or sites that don't use the Cart module.

cgdrupalkwk’s picture

Any updates regarding this? I see you can add and delete line items on the "edit order" screen, but how do you add custom line items to this screen. I can't find a way to easily add data to a line item field when adding a line item using this screen.

You can easily change which line item fields are displayed in most other views of order details by referencing the "Line item reference" field to a view other than the default "commerce_line_item" view under the "store>configuration>order settings>manage display" screen. Perhaps this same method could be used to allow users to decide which line item fields to expose to the edit order form.

n8tron’s picture

Needed. I need to be able to update line items per order after completion. A vertical tab for attached line items would be nice.

bojanz’s picture

Status: Active » Fixed

The Inline Entity Form now provides this functionality (as a custom widget for the line item reference field).

rszrama’s picture

Category: task » feature
Priority: Normal » Minor
Status: Fixed » Active

I'm going to reopen this with a lower priority. IEF solves the immediate need for the form, but it would still be good practice to have a core form for places where it may need to be used outside of IEF.

Christopher Riley’s picture

Has there been any progress or thought given to this? I am working on a very specialized project that uses custom products with many calculations being done on the backend, however IEF does come close it gives me many unexpected results that would be much easier to deal with if the Admin Line Item Edit screen was just a standalone form.

markwk’s picture

I don't want to jump in on this issue per se but if you are looking for an easy way to edit line items, you can create a view and use VBO "modify entity values" to do this. Not a pure edit form but it works. Hopefully that can help someone else who lands on this page.

rszrama’s picture

I think editable fields should work, too, but I haven't tested it yet to make sure.

BrightBold’s picture

In my use case, switching to IEF works but makes the admin less usable. All I want to do is add one additional column with an editable field - a serial number for a gift card that the client wants to record before they mail out purchased gift cards. Switching the line item widget to IEF does allow them to edit that field (after an extra click), but removes the ability to edit Quantity and Custom Amount without first clicking "edit."

It would be really nice to be able to edit the line item manager widget if desired. I have found everything else in Commerce so easily customizable that it's weird to find an instance where it's not!

BrightBold’s picture

I think editable fields should work, too, but I haven't tested it yet to make sure.

Does anyone have editable fields working here? I tried making a new view based on the Line item block display and using an editable field. The field shows up but is not editable, so I'd love tips if someone has done this successfully.

jenlampton’s picture

Title: Create a line item add / edit form » Create a line item add / edit form (or use a view)
Issue summary: View changes

My use case is this:
Each of my products have a single select field added with the Commerce Customizable Products module. The value of that select field is very important. I'm building a puppy training website, and this field holds the nid/name of the dog registered for the class. Since people often have more than one dog, this field needs to be completed for every single product line item.

When people sign themselves up for puppy training, they use the cart and since the cart is a view, it's easy enough to add the new field to the cart form by overriding the view.

However, if an administrator needs to change an existing order, for example moving people from one class to another (by removing one line item from an order and adding another product by sku) they are unable to set the value of this additional field. All they are able to change about the line item is the unit price and quantity.
Only local images are allowed.

If the "Line Item Manager" field widget were instead to use a view, like the display (commerce_line_item_table) or the cart (commerce_cart_form) then it would be easy for us to add additional options to the admin interface as well as the user-facing interfaces.

My work-around will be to use the Inline Entity Form for the time being.

Anybody’s picture

For others who are looking for a working solution, have a look at this guide using inline entity forms. It's simple and robust.
http://julian.pustkuchen.com/node/584

gumdal’s picture

Reply to #20
I tried configuring my Line Item review field as Editable field, but it fails to work. The field is shown as editable but nothing is saved when I actually enter some text hit the 'save' button.

My use case:
I am running a catering service website where user orders food and it is assigned to vendor by a website admin based on availability. After the successful completion of the order (A set of Line Items as well) user now gets a chance to rate + review the individual line item because each line item in a single order can be assigned to multiple vendors.

Success story in my usecase:
I am able to configure Inline Entity Form for the Vendor Reference entity assignment when a website admin "Edits" the Line item (through Order -> Edit) and can assign a vendor reference entity to the line item.

Failure story in my usecase:
I also have Rating & Review for each line item. I have created a view where I will list down Line items of the user and I have used Editable Field for Review field. Surprisingly my 5 star rating module does accept votes and it saves the vote by the user for the line item, however, the text entered by user in the editable review field is never saved for some reason.

Any help by the community to tackle my problem would be highly appreciated.

Thanks,
Raj Pawan G

Atec Zhou’s picture

My situation is the same with #19 and #23.
Custom fileds on line item type seems editable, but after click "update Line item", its value is not saved.
According to http://julian.pustkuchen.com/node/584 that #22 mentioned, I created a simple text field , but it doesn't work.

wdseelig’s picture

Thank you very much for this post.