Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Title says it all, once an order is created, how can I edit the values submitted by a user?
Comments
Comment #1
gantenx CreditAttribution: gantenx commentedSame problem. Admin cannot edit
nor createitems using custom line items.Is there any approaches to get this work?
Comment #2
n8tronSubscribe
Comment #3
ressa CreditAttribution: ressa commentedAlso, 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?
Comment #4
ressa CreditAttribution: ressa commentedI 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.
Comment #5
iLLin CreditAttribution: iLLin commented@ressa, great find man. I will check it out this weekend. Thanks dood!
Comment #6
ressa CreditAttribution: ressa commented@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:
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 :-)
Comment #7
ressa CreditAttribution: ressa commentedA 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
Comment #8
rszrama CreditAttribution: rszrama commentedIf I'm not mistaken, this is now fixed through http://drupal.org/project/inline_entity_form.
Comment #9
ressa CreditAttribution: ressa commentedSounds great, thanks!