I am attempting to add a local task here (/admin/commerce/orders/{order#}). This local task should contain a view that takes the userid from the current order and displays that users order history.
I believe I have the view set up correctly and I can successfully add a local task here (admin/people/%user/orders) by adding the following to my links.tasks.yml:
custom_module.people.user_orders:
route_name: view.orders.page_2
base_route: entity.user.canonical
title: 'Orders'
parent: entity.user.canonical
weight: 100
If I go to /admin/people/1/orders while this task is uncommented, I do indeed get a list of this user's orders and the tab itself lives under the Home>Administration>People part of the site.
However, if I remove this local task and replace it with the following, I get an error:
custom_module.commerce_order.user_orders:
route_name: view.orders.page_2
base_route: entity.commerce_order.canonical
title: 'Orders'
parent: entity.commerce_order.canonical
weight: 16
class: '\Drupal\custom_module\Plugin\Menu\UserOrdersDynamicTab'
UserOrdersDynamicTab.php:
namespace Drupal\custom_module\Plugin\Menu;
use Drupal\Core\Menu\LocalTaskDefault;
use Drupal\Core\Routing\RouteMatchInterface;
class UserOrdersDynamicTab extends LocalTaskDefault
{
/**
* {@inheritdoc}
*/
public function getRouteParameters(RouteMatchInterface $route_match)
{
return [
'user' => \Drupal::routeMatch()->getParameter('commerce_order')->getCustomerId(),
];
}
}
Uncommenting this version and commenting out the previous local task results in an error when I visit /admin/people/1/orders. To be clear, I am trying to create a local task that passes a parameter to a view. Below is the error I am getting. Thank you in advance for any help you can offer! (This is my first time posting a question here so I'm also interested in corrections to my post.)
The website encountered an unexpected error. Please try again later.
Error: Call to a member function bundle() on null in Drupal\commerce_shipping\Access\ShipmentCollectionAccessCheck->access() (line 52 of modules/contrib/commerce_shipping/src/Access/ShipmentCollectionAccessCheck.php).
Drupal\commerce_shipping\Access\ShipmentCollectionAccessCheck->access()
call_user_func_array() (Line: 160)
Drupal\Core\Access\AccessManager->performCheck() (Line: 136)
Drupal\Core\Access\AccessManager->check() (Line: 93)
Drupal\Core\Access\AccessManager->checkNamedRoute() (Line: 327)
Drupal\Core\Menu\LocalTaskManager->getTasksBuild() (Line: 358)
Drupal\Core\Menu\LocalTaskManager->getLocalTasks() (Line: 95)
Drupal\Core\Menu\Plugin\Block\LocalTasksBlock->build() (Line: 171)
Drupal\block\BlockViewBuilder::preRender()
call_user_func_array() (Line: 101)
Drupal\Core\Render\Renderer->doTrustedCallback() (Line: 772)
Drupal\Core\Render\Renderer->doCallback() (Line: 363)
Drupal\Core\Render\Renderer->doRender() (Line: 435)
Drupal\Core\Render\Renderer->doRender() (Line: 201)
Drupal\Core\Render\Renderer->render() (Line: 463)
Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 47)
__TwigTemplate_82330771d2235f13341d75dc3dba6b0551e4091dc4e3e3af75b58a51080d8b70->doDisplay() (Line: 405)
Twig\Template->displayWithErrorHandling() (Line: 378)
Twig\Template->display() (Line: 390)
Twig\Template->render() (Line: 55)
twig_render_template() (Line: 384)
Drupal\Core\Theme\ThemeManager->render() (Line: 422)
Drupal\Core\Render\Renderer->doRender() (Line: 201)
Drupal\Core\Render\Renderer->render() (Line: 463)
Drupal\Core\Template\TwigExtension->escapeFilter() (Line: 86)
__TwigTemplate_8396bbb6a446449db2b4f79819d5586f73fc0a7bf41d2501e27ba28c058bb7b1->doDisplay() (Line: 405)
Twig\Template->displayWithErrorHandling() (Line: 378)
Twig\Template->display() (Line: 390)
Twig\Template->render() (Line: 55)
twig_render_template() (Line: 384)
Drupal\Core\Theme\ThemeManager->render() (Line: 422)
Drupal\Core\Render\Renderer->doRender() (Line: 201)
Drupal\Core\Render\Renderer->render() (Line: 162)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 163)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse() (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray()
call_user_func() (Line: 142)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (Line: 163)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass() (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 23)
Stack\StackedHttpKernel->handle() (Line: 708)
Drupal\Core\DrupalKernel->handle() (Line: 19)