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.
Create a registration. Remove it from the cart. The registration still exists, with status of pending.
User decides they really do want to register and tries to add it to the cart - but they can't since the registration already exists.
I would expect removing registration from the cart to automatically cancel the registration (and I'm assuming if the registration is cancelled, the registrant would be allowed to register again.
Ideally, this would be in the code, but I'd be happy to have a reaction rule to do it.
Comments
Comment #1
pglatz CreditAttribution: pglatz commentedI tried creating a rule to do this. I was able to get the registration id, and am calling registration_delete_multiple(array($reg_id))
It deletes the registration correctly, but is displaying the wrong product name in the status message. I've traced this to a call in commerce_cart_line_item_delete_form_submit().
$line_item_wrapper->data->line_item_label contains the correct product id.
but $line_item_wrapper->data->commerce_product['und'][0]['product_id'] points to an unrelated product.
Any suggestions on a better way to do this?
Comment #2
asirjacques CreditAttribution: asirjacques commentedHi,
I've post my solution here. May be that could help you both.
Regards,
Comment #3
gcbI think deleting the registration is overzealous: an option to create a smart behavior using rules is the most commerce-y way to solve this, but I could also see simply having a couple of checkbox configuration options and hard-coding the behavior. Anyone have preferences here? Here are the behaviors I think could be available when an item is removed from a cart:
1. Do nothing to the registration. (Current behavior: sensible default)
2. Delete the registration item.
3. Change the registration item's state to a selectable option.
Does anyone see any other sensible use cases? Do any of these 3 seem unnecessary?
I have a site where 3rd parties can pay for someone's registration, and the registrations carry a lot of extra data, so you might have a situation where someone add the registration to their cart, then removes it so their employers can add it to *their* cart to pay for it. In that case we don't want to touch the registration when it is removed. Etc.
Thoughts welcome, would be nice to get an elegant solution in before a 1.0 release.
Comment #4
artbussy CreditAttribution: artbussy commentedDon't know if it's possible to have a waiting list. Owners of removed items could receive an email through Rules stating that they are placed on the waiting list for a limited period of time. Within this time limit they either confirm or ignore (leading to cancellation of the resevation).
Comment #5
bobojo CreditAttribution: bobojo commented@Lynxas: Your code was quite helpful for my use case. I've made some modifications to protect against potential errors, so I thought I'd post my version here.
EDIT: Added some comments. Also, registration_delete() doesn't exist, which seems like it could be a bit of an oversight, but that's fine. So I updated it to use registration_delete_multiple() like the original code.
Comment #6
MrPaulDriver CreditAttribution: MrPaulDriver commentedI think this is a much needed feature which ought to be coded into the module.
Comment #7
norwegian.blue CreditAttribution: norwegian.blue commented@bobojo
Thanks - your code was exactly what I was looking for.
I agree @MrPaulDriver - this feature should be included in the module
Comment #8
gcbA default rule has been added to the module to resolve this. It is disabled by default, but you can just enable the rule to get this behavior. The rule is called "Delete registration with line item". Code is here. http://cgit.drupalcode.org/registration_commerce/tree/registration_comme...