Fatal errors when switching to "Registration Link" or "Registration Form" field formatters

Created on 31 January 2023, almost 2 years ago
Updated 3 February 2023, almost 2 years ago

On the product variation type "Manage display" UI:

1. Setting the format to "Registration type" prints the type correctly when viewing the product

2. Setting the format to "Registration link" generates a 500 error when viewing the product:

Symfony\Component\Routing\Exception\MissingMandatoryParametersException: Some mandatory parameters are missing ("commerce_product") to generate a URL for route "entity.commerce_product_variation.registration.register". in Drupal\Core\Routing\UrlGenerator->doGenerate() (line 181 of core/lib/Drupal/Core/Routing/UrlGenerator.php).
Backtrace last:
Drupal\Core\Routing\UrlGenerator->getInternalPathFromRoute() (Line: 292)
Drupal\Core\Routing\UrlGenerator->generateFromRoute() (Line: 105)
Drupal\Core\Render\MetadataBubblingUrlGenerator->generateFromRoute() (Line: 765)
Drupal\Core\Url->toString() (Line: 182)
Drupal\Core\Utility\LinkGenerator->generate() (Line: 64)
Drupal\Core\Utility\LinkGenerator->generateFromLink() (Line: 164)
Drupal\Core\Link->toString() (Line: 110)
Drupal\registration\Plugin\Field\FieldFormatter\RegistrationLinkFormatter->viewElements() (Line: 89)

3. Setting the format to "Registration form" generates a 500 error when viewing the product:

Error: Call to a member function getSetting() on null in Drupal\registration\HostEntity->isEnabledForRegistration() (line 423 of modules/contrib/registration/src/HostEntity.php).
Backtrace last:
Drupal\registration\Form\RegisterForm->form() (Line: 106)

I had these errors on the commerce site I am building, and reproduced immediately on a vanilla commerce composer install with no extra module enabled except for registration and commerce_registration.

I followed the README instructions here:
https://git.drupalcode.org/project/commerce_registration/-/blob/3.0.x/RE...

Am I missing something ?

Environments tested with the errors:
- Ubuntu 22.04 / Drupal 9.5.1 / PHP 8.1.14 / Commerce 8.x-2.32 / Registration 3.0.0-beta2
- Ubuntu 22.04 / Drupal 10.0.2 / PHP 8.1.14 / Commerce 8.x-2.33 / Registration 3.0.0-beta3

πŸ› Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

πŸ‡«πŸ‡·France pmunch

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @pmunch
  • Assigned to john.oltman
  • πŸ‡ΊπŸ‡ΈUnited States john.oltman

    Thanks for the report, I will take a look soon.

  • πŸ‡«πŸ‡·France pmunch

    Thanks John.
    Tell me if you need a dump of the test site.

  • πŸ‡ΊπŸ‡ΈUnited States john.oltman

    That would be great @pmunch - I just sent you my email address via Drupal contact form. Thank you

  • Same here, D 9.5.2, Php 8.1.14, latest beta module in a wodby docker setup with Drupal managed by composer. Maybe unrelated - the unpaid test orders (manual payment) can be seen in the orders view of commerce as complete (although pending in the payments subtab) but never arrive in the prod. variationsβ€˜ registration tabs despite using custom event order item and order types. Promoting the payment status to complete doesnβ€˜t move the reg. into their slot, which may be intended, however? Regards, dgwolf

  • πŸ‡ΊπŸ‡ΈUnited States john.oltman

    Reproduced issue locally using the site dump from @pmunch. Have to take care of something other things right now but should be able to debug and commit a fix within the next day or two. Most likely the issue with unpaid test orders is unrelated, that may become a separate issue. More soon.

  • πŸ‡ΊπŸ‡ΈUnited States john.oltman

    @pmunch, I'll push up fixes within the next day for you and anyone else that is using commerce in this way. The reason I hadn't seen this issue before is you are not using an Add to Cart form for your product, which one would typically do if you have commerce installed. Maybe you were going to get to that eventually, but briefly, to make things work better, you would use these admin pages to setup an Add to Cart form on your product detail page:

    admin/commerce/config/product-types/event/edit - check the box for "inject product variation fields"

    admin/commerce/config/product-variation-types/event_offer/edit/display - adjust the weights of fields here (manually if necessary) to get the product page to show things in the order you want - Registration should not be an enabled field since there is a special form in checkout

    admin/commerce/config/product-types/event/edit/display - hide the Variations label and change the format for it to "Add to cart form"

    admin/commerce/config/order-item-types/default/edit/form-display/add_to_cart - change the widget for Purchased Entity to "Product variation title (spaces available)" - that should be the only enabled field

    If you do those things you will avoid the exceptions you reported and make better use of the module. The idea is that people register via checkout and not from the product page.

  • πŸ‡«πŸ‡·France pmunch

    Hi John, many thanks for your return.

    I'm an experienced Drupal integrator, but this is my first real approcach with commerce, so sorry if I still miss some concepts or best practices.

    As you mentionned, I was on the track to not use the Add to cart form, to keep the process straightforward as only registrations are sold.

    While awaiting your fixes, I will however setup the solution you suggest to see how it fits with the project.

  • Issue was unassigned.
  • Status changed to Fixed almost 2 years ago
  • πŸ‡ΊπŸ‡ΈUnited States john.oltman

    No problem @pmunch, the flow will vary for different sites.

    Fix committed and will be in a new release within a couple days.

    @dgwolf, registrations should show in their respective tabs - if you don't mind can you open a separate issue for that so we can track it. Also let me know if you can provide a site dump to help with debugging. Thank you.

  • πŸ‡«πŸ‡·France pmunch

    Thanks a lot John.

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

Production build 0.71.5 2024