Title says it all, once an order is created, how can I edit the values submitted by a user?

Comments

gantenx’s picture

Same problem. Admin cannot edit nor create items using custom line items.

Is there any approaches to get this work?

n8tron’s picture

Subscribe

ressa’s picture

Also, is there a way for the customers to edit a product within their order? Or is deleting the product and starting over the only solution for now?

ressa’s picture

I just saw a video by Randy Fay where he used the Editable Fields module to do this: http://drupal.org/project/editablefields

Around 10 minutes into the video: http://commerceguys.com/blog/commerce-module-tuesday-commerce-customizab...

I seem to have made it work for administrators and registered users, by selecting 'Edit own orders of any type' under 'Permissions', but so far, not for anonymous users.

iLLin’s picture

@ressa, great find man. I will check it out this weekend. Thanks dood!

ressa’s picture

@iLLin, you're welcome :-)

I realized that customers could edit custom fields after an order is submitted, which shouldn't be allowed, and perhaps only before the Checkout process begins, which means editablefields should only be activated for customers in the 'Shopping cart block (Commerce Order)' View and 'Shopping cart form (Commerce Order)'.

For example, the View 'Line items (Commerce Line Item)' is used to show the finalized order, which means that if editablefields is added to that View, without limiting access somehow, customers can update finalized orders at user/8/orders/12.

The View 'Shopping cart summary (Commerce Order)' is used for the Checkout process, where orders probably shouldn't be editable.

To allow only administrators to edit fields in submitted orders, but not have 'Edit this field'-links displayed on invoices, I tried different things, but then got the idea to see if there was something in the editablefields module which could help, and the following seems to do it:

To only allow editing of orders by admin on the Order View Page (arg(2) == "orders" && $user->uid != 1) and never on invoice pages (arg(4) == "invoice" || arg(2) == "invoices"), change linie 194 in editablefields.module from:

if (!entity_access('update', $entity_type, $entity) || !field_access('edit', $field, $entity_type, $entity)) {

To:

global $user;
if (!entity_access('update', $entity_type, $entity) || !field_access('edit', $field, $entity_type, $entity) || (arg(2) == "orders" && $user->uid != 1) || arg(4) == "invoice" || arg(2) == "invoices") {

I tried to copy the function 'editablefields_field_formatter_view' from editablefields.module to template.php, but it's not picking it up for some reason, so I will just have to hack the module, and remember when I update :-)

ressa’s picture

A patch is being tested here, which might allow editing of existing order, I haven't tried it yet: Allow commerce_cart_add_to_cart_form() to edit line items

rszrama’s picture

Status: Active » Fixed

If I'm not mistaken, this is now fixed through http://drupal.org/project/inline_entity_form.

ressa’s picture

Sounds great, thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.