Line item status / partial order fulfillment

The Use Case is partial fulfillment of orders.

About to install Commerce, just want to sense-check how I'll configure to get this functionality. The idea of individual statuses for line items was mentioned here: http://www.drupalcommerce.org/node/79 but I haven't seen anything else on it.

Our specific scenario is that we run a community bulk food buyers group, using Ubercart 6 (http://www.dulra.org/ecoshop). We don't carry stock: customers order online and once a week we pull up a simple view which collect all products that have been ordered in the past week, ie line items from orders with Status "New Order" "Processing" or "Payment Received". This list of products is submitted to our supplier, who then ship the items to us. When we break these shipments out into individual customer orders. Invariably there are some missing items, so we will need to flag these for reorder the following week.

So my approach would be to have a status for individual line items as well as the overall order status. Orders that are still incomplete could have line items with a mix of statuses, we'd want an easy way to update all line item statuses for the current week's orders (single screen rather than going into individual orders), and be able to use these when generating the list of products to be ordered for the following week. It would also be good to generate a email (Rules?) to the customer informing him of the delay.

Possibly related Use Case is where an item that was ordered is no longer available. Ideally we'd be able to signify this by a simple change of status in the same line item list, set up a Rule that would update the corresponding order total, and under certain conditions, trigger a Paypal refund and email to the customer explaining the situation.

I'm about to install Commerce quickstart and try doing this, but if there's a ready-made solution or a better approach to addressing this Use Case, I'd love to hear about it!


Posted: Jan 6, 2012


frost on January 6, 2012

(progress update)
Added a field to line item (Boolean "Received")

Updated the line item view that is used when viewing an order, so I can now see the Received field when viewing any individual order.

Created a new standalone View of all line items, which includes the Received field.

Next steps (need help here):

1. Need to have an editable version of the Received field when editing an individual customer order. I.e., where do I modify the line item part of the order edit screen?

2. Need to have editable version of the field in my new standalone view (I can see it, but it's read-only. There is an editable Quantity field, so I need something along those lines, but dont know where to start)

3. Need to be able to restrict the results of my standalone View to just those line items that are associated with Orders of a particular status. I assume this requires a Relationship with Orders?

Suggestions/help much appreciated!

nicholas on March 14, 2012

I'm also looking for a way of doing this. so far I've been able to get the custom field into each line item (but not able to get it to update as yet). what I've done is used a hook_field_widget_form_alter to add the field and headers I need to the $element array. Using a modified theme_commerce_line_item_manager to render the line items with the field. I did this by using hook_theme_registry_alter to tell drupal to use my custom function instead of commerce's original theme_commerce_line_item_manager function.

will update as and when i get it working :)

Fran Carstens on December 22, 2015

Using some of the ideas suggested above I was able to do this using core modules and Editable Views + Requirements.

  • Create a text-list field on your line item type.
  • Add your status options and select your default.
  • Save the field.
  • Go to field display and hide it.
  • Create a new “line item status” view.
  • Format the view as “editable view table”.
  • Add your relevant fields including the “line item status (editable)” field.
  • Save.
  • Boom, you’re done.

To restrict the view based on status use the Filter option, and add your new field. Expose the field so you can filter on the fly.

Now you can even use Rules to auto increment the statuses if you like.