Error while trying to create a local task for user order history

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: 'Drupalcustom_modulePluginMenuUserOrdersDynamicTab' 

UserOrdersDynamicTab.php:

 namespace Drupalcustom_modulePluginMenu;  use DrupalCoreMenuLocalTaskDefault; use DrupalCoreRoutingRouteMatchInterface;  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 Drupalcommerce_shippingAccessShipmentCollectionAccessCheck->access() (line 52 of modules/contrib/commerce_shipping/src/Access/ShipmentCollectionAccessCheck.php). Drupalcommerce_shippingAccessShipmentCollectionAccessCheck->access() call_user_func_array() (Line: 160) DrupalCoreAccessAccessManager->performCheck() (Line: 136) DrupalCoreAccessAccessManager->check() (Line: 93) DrupalCoreAccessAccessManager->checkNamedRoute() (Line: 327) DrupalCoreMenuLocalTaskManager->getTasksBuild() (Line: 358) DrupalCoreMenuLocalTaskManager->getLocalTasks() (Line: 95) DrupalCoreMenuPluginBlockLocalTasksBlock->build() (Line: 171) DrupalblockBlockViewBuilder::preRender() call_user_func_array() (Line: 101) DrupalCoreRenderRenderer->doTrustedCallback() (Line: 772) DrupalCoreRenderRenderer->doCallback() (Line: 363) DrupalCoreRenderRenderer->doRender() (Line: 435) DrupalCoreRenderRenderer->doRender() (Line: 201) DrupalCoreRenderRenderer->render() (Line: 463) DrupalCoreTemplateTwigExtension->escapeFilter() (Line: 47) __TwigTemplate_82330771d2235f13341d75dc3dba6b0551e4091dc4e3e3af75b58a51080d8b70->doDisplay() (Line: 405) TwigTemplate->displayWithErrorHandling() (Line: 378) TwigTemplate->display() (Line: 390) TwigTemplate->render() (Line: 55) twig_render_template() (Line: 384) DrupalCoreThemeThemeManager->render() (Line: 422) DrupalCoreRenderRenderer->doRender() (Line: 201) DrupalCoreRenderRenderer->render() (Line: 463) DrupalCoreTemplateTwigExtension->escapeFilter() (Line: 86) __TwigTemplate_8396bbb6a446449db2b4f79819d5586f73fc0a7bf41d2501e27ba28c058bb7b1->doDisplay() (Line: 405) TwigTemplate->displayWithErrorHandling() (Line: 378) TwigTemplate->display() (Line: 390) TwigTemplate->render() (Line: 55) twig_render_template() (Line: 384) DrupalCoreThemeThemeManager->render() (Line: 422) DrupalCoreRenderRenderer->doRender() (Line: 201) DrupalCoreRenderRenderer->render() (Line: 162) DrupalCoreRenderMainContentHtmlRenderer->DrupalCoreRenderMainContent{closure}() (Line: 564) DrupalCoreRenderRenderer->executeInRenderContext() (Line: 163) DrupalCoreRenderMainContentHtmlRenderer->renderResponse() (Line: 90) DrupalCoreEventSubscriberMainContentViewSubscriber->onViewRenderArray() call_user_func() (Line: 142) DrupalComponentEventDispatcherContainerAwareEventDispatcher->dispatch() (Line: 163) SymfonyComponentHttpKernelHttpKernel->handleRaw() (Line: 80) SymfonyComponentHttpKernelHttpKernel->handle() (Line: 58) DrupalCoreStackMiddlewareSession->handle() (Line: 48) DrupalCoreStackMiddlewareKernelPreHandle->handle() (Line: 106) Drupalpage_cacheStackMiddlewarePageCache->pass() (Line: 85) Drupalpage_cacheStackMiddlewarePageCache->handle() (Line: 48) DrupalCoreStackMiddlewareReverseProxyMiddleware->handle() (Line: 51) DrupalCoreStackMiddlewareNegotiationMiddleware->handle() (Line: 23) StackStackedHttpKernel->handle() (Line: 708) DrupalCoreDrupalKernel->handle() (Line: 19) 
This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

Error while trying to create a local task for user order history

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.