1 minutters læsning

As I wrote earlier, I am creating a registration system using Drupal Commerce for Vejle Idrætshøjskole. For one of our course type, we need the customer to be able to select subjects during the checkout process. We decided to do it on a custom line item using custom customizable products where we added the subjects as a field.

Screenshot of registration system

The subjects is not the same on all of our courses on that course type, so I attached the subjects using an entityreference. Using the entityreference module under the settings for the field, I can use Views: Filter by an entityreference view to select the entities, I want to show for for the entityreference field on the custom line item on the add to cart form.

However, when using the add to cart form, I could not simply choose the current page node id for the contextual filter for the referenced entities. Instead I had to use a token to make the reference from the currently chosen product to the course display content type with the referenced subjects.

Luckily, that is possible using the patch from the issue: Dynamic Views Arguments Using Tokens. Now I was able via the settings page for the subjects field on the custom line item type to supply an argument for my view using this token: [commerce-line-item:commerce-product:product-id].

When I resolved this issue issue everything worked beautifully. How do you handle registrations with Drupal Commerce?

Kommentarer

You can be the first to add a comment below.

Leave a Comment

Din e-mail bliver ikke offentliggjort. Obligatoriske felter er markeret Required fields are marked *.

Indlæser...
Your email address will not be published.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.