Describe your bug or feature request.

Prior to the new OMS in 3.3.x, and within an order's "Edit" tab, you could enable a "Duplicate" order item button. This functionality still exists IF the order "Edit" tab is enabled in 3.3.x, but the "Duplicate" functionality DOES NOT exist as an inline operation in the OMS order view.

In 3.3.x:

  1. On admin/commerce/config/order-types/default, enable "Show the edit tab and operations link for orders ..."
  2. On admin/commerce/config/order-types/default/edit/form-display, make sure the "Order items" "Widget" is "Order items (Experimental)", then click the cog to configure it. Enable "Allow users to duplicate order items". (This is required to show the "Duplicate" button in the "Edit" tab below.)
  3. Create an order and view it in the adminterface.
  4. In the order items display, there are only inline operations for "edit" and "delete".
  5. Click the order's deprecated "Edit" tab. You'll see an additional "Duplicate" button.

The expectation is:

  1. "Duplicate" functionality should exist in the new 3.3.x OMS non-Edit-tab workflow.
  2. A "duplicate" inline operation should appear after "edit" and "delete".

Issue fork commerce-3630674

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

morbus iff created an issue. See original summary.

morbus iff’s picture

Title: "Duplicate" inline operation missing in "experimental" widget » "Duplicate" inline operation missing on new OMS order view
Issue summary: View changes
morbus iff’s picture

Title: "Duplicate" inline operation missing on new OMS order view » "Duplicate" inline operation missing on order view
Issue summary: View changes
tbkot’s picture

Working on it

vipin.j made their first commit to this issue’s fork.

tbkot’s picture

Status: Active » Needs review
vipin.j’s picture

Status: Needs review » Needs work

duplicate action link not working! AJAX request failed with following error:

The website encountered an unexpected error. Try again later.

Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException: The "commerce_order_item" entity type did not specify a "duplicate-form" form class. in Drupal\Core\Entity\EntityTypeManager->getFormObject() (line 209 of core/lib/Drupal/Core/Entity/EntityTypeManager.php).
Drupal\Core\Entity\HtmlEntityFormController->getFormObject() (Line: 58)
Drupal\Core\Controller\FormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->{closure:Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber::wrapControllerExecutionInRenderContext():121}() (Line: 634)
Drupal\Core\Render\Renderer::{closure:Drupal\Core\Render\Renderer::executeInRenderContext():634}()
Fiber->start() (Line: 635)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->{closure:Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber::onController():96}() (Line: 183)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 53)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 28)
Drupal\Core\StackMiddleware\ContentLength->handle() (Line: 32)
Drupal\big_pipe\StackMiddleware\ContentLength->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 53)
Drupal\Core\StackMiddleware\AjaxPageState->handle() (Line: 54)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle() (Line: 745)
Drupal\Core\DrupalKernel->handle() (Line: 19)

jsacksick’s picture

Status: Needs work » Reviewed & tested by the community

@vipin.j: You need to clear caches after pulling the code...

  • jsacksick committed 5e38ec06 on 3.x authored by tbkot
    feat: #3630674 "Duplicate" inline operation missing on order view
    
    By:...
jsacksick’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

fenstrat made their first commit to this issue’s fork.

fenstrat’s picture

Status: Fixed » Needs review

Reopening for a follow-up, see MR !758.

Since this was committed, deleting an order item that doesn't belong to an order throws when menu_link_content is enabled:

Drupal\Core\Entity\EntityStorageException: Parameter "commerce_order" for route "entity.commerce_order_item.duplicate_form" must match "[^/]++" ("" given) to generate a corresponding URL.

menu_link_content_entity_predelete() generates the URL of every link template via uriRelationships(). OrderItem::toUrl() returns <nolink> when there's no order, but only for edit-form and delete-form (#3574237), so the new duplicate-form link falls through with an empty commerce_order parameter.

The MR replaces that hardcoded list with a check for any link template containing {commerce_order}, so future order-scoped links are covered too. It adds kernel tests to OrderItemTest:

  • testToUrl(): every order-scoped link returns <nolink> without an order, and generates the real admin URL once the item belongs to one.
  • testDeleteWithoutOrder(): deletes an order item without an order with menu_link_content enabled, mirroring ProductVariationTest::testDeleteIncomplete().

Both tests fail without the fix.

This contribution was developed with AI assistance throughout the process. I reviewed the change, understand it, and take responsibility for its correctness.

tbkot’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @fenstrat for finding it and for the fix. It looks good to me

jsacksick’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.