Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Would it be possible to incorporate the registration price into the registration node?
It seems pretty long winded to require a new registration type for each differently priced registration. Especially so, with all the permissions settings that need to be configured for each registration type.
I agree this is not a big effort for an occasional conference, but for an organisation running a great many events this would quickly become unmanageable.
Comments
Comment #1
MrPaulDriver CreditAttribution: MrPaulDriver commentedComment #2
stufke87 CreditAttribution: stufke87 commentedI am looking for the same thing. Did you manage to fix this or did you find an other solution?
Comment #3
lance.gliser CreditAttribution: lance.gliser commentedThis can be done through a custom module already, actually. Here's the relevant bits:
File: custom.module
This file is being used as a routing file a the logic in custom/registration/registration.module.inc
custom/registration/registration.module.inc
I do kind of wonder why this isn't a stock feature... Would make sense. Maybe the authors would be kind enough to integrate this code?
Comment #4
MrPaulDriver CreditAttribution: MrPaulDriver commentedThis is a bit over my pay grade, but I too would welcome an opinion from the maintainers.
Comment #5
gcbThis is a good feature request: I'll look into how we might accommodate this. A little more about how it works currently:
1. It's still in beta! Partly because we are still working this stuff out.
2. Because pricing for these things is always extremely custom in our experience, the built-in price tool is intentionally simple. You can set your own prices by implementing "hook_registration_commerce_calculate_price". Here's an example from one of my projects:
/**
* Implements hook_registration_commerce_calculate_price().
*/
function custom_module_registration_commerce_calculate_price($registration, $info) {
$result = array();
$registration_wrapper = entity_metadata_wrapper('registration', $registration);
$event = node_load($registration->entity_id);
$event_wrapper = entity_metadata_wrapper('node', $event);
$price = $event_wrapper->field_registration_price->value();
$result = array(
'amount' => $price * 100,
'currency_code' => $event_wrapper->field_currency->value(),
);
}
return $result;
}
This essentially does exactly what you are requesting: it uses a field on the node (field_registration_price) to set the price.
Perhaps the most sensible thing would be to have the pricing UI on the registration type allow you to pick a price field to use for the price, and to look for that field on the Registration's host entity.
Comment #6
gcbcommit #015ef35 offers an initial implementation. You'll now see a field selector on the registration commerce settings tab on your registration type. It only displays "Price" fields. If you add a Price field to your host entity type and set the value, then point the registration type to that field, you should have what you want here.
Comment #7
MrPaulDriver CreditAttribution: MrPaulDriver commentedThanks for this. I'm a bit busy with another project but hope to take a close look very soon.
Comment #8
alibama CreditAttribution: alibama commentedI'm testing this now - if I add a price field to the registration I still can't override the value set in registration commerce field - whatever value in there seems to win...hold up - I may have misunderstood how this works, back in a sec - ok yeah = works great! thanks
Comment #9
gcbDon't add the price field to the registration type: that would let the registrants pick their own price. Look at my instructions again:
"If you add a Price field to your host entity type".
So if you have an Event Content Type, add a Price field to that Content Type. The same content type that has a Registration field that links to the Registration Type.
Comment #10
alibama CreditAttribution: alibama commentedyeah - sorry about that = registration_commerce +1, my literacy comprehension -1
Comment #12
yaach CreditAttribution: yaach commented@gcb
I have added a price field for my content type. I need multiple price tiers, so I made the field with unlimited values and then on a node of my custom content type I set the price field with three values, $20, $10, $0. Then under the Registration Commerce Settings tab of the Registration Type I am using on my custom content type, I am selecting the price field to be used.
On another browser, I go to my node landing page and type in my email and click Register, it takes me to the Shopping cart with value $0 for registration.
At what point I can make the user choose the price they need to pay: $20, $10, $0 and then the chosen price should be carried out to the shopping cart.
Please help!
Comment #13
gcbThat's not supported with the automated price setter, I'm afraid. You'll need to add a field to your registration type to allow the user to select a price, and implement
hook_registration_commerce_calculate_price()
to set it. You can probably do some fancy stuff with a hook_form_alter to allow the price options to be selected on the event edit screen, and then insert those options on the registration form, if that's a requirement.Comment #14
yaach CreditAttribution: yaach commentedOn comment #9 you mentioned "...registrants pick their own price...", that's probably what I am looking for. My use case is that an event has multiple prices tiers and actually will depend on the user role, but that's a more complicated solution. I would be happy if the registrant can choose the price.
Comment #15
gcbSorry if my answer in #9 implied that the module would do this all with just configuration: you'll have to write custom code to make that work. Here's an example: