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.
Scheduling support is being introduced in #1316236: Provide option to set a date to automatically close registration. This adds 2 new fields to the database. Commerce Registration doesn't currently handle these 2 new fields in it's validate/submit form handlers, so the dates never get set properly.
Comments
Comment #1
mrfelton CreditAttribution: mrfelton commentedAttached patch added the scheduling field support, and also removes some of the duplication in the submit and validation handlers. There doesn't seem to be much point in duplicating the code from registration module's own submit and validation handlers, so instead of doing that, we just pass the relevant data through to registration modules own validation and submit handlers.
Comment #2
mrfelton CreditAttribution: mrfelton commentedAttached patch also ensure that the form altering on the add to cart form properly checks the registration status using registration_check_status().
This all works to ensure that the schedule dates get updated/set properly when editing registration settings on products or product displays. However, we also need to stop people from actually being able to purchase the product if the status is disabled.
Comment #3
mrfelton CreditAttribution: mrfelton commentedI'm not sure how to best handle that. Do we force set the products status to disabled when the registration is deemed to be closed, and open again when it opens? Or, is changing the products status too much.
Comment #4
mrfelton CreditAttribution: mrfelton commentedUpdated again, this adds an implementation of hook_registration_status_alter() which is used to enable/disable the product based on the schedule.
Comment #5
mrfelton CreditAttribution: mrfelton commentedPatch updated to remove trailing whitespace.
Comment #6
jpontani CreditAttribution: jpontani commentedSetting to needs work since levelos went a bit different route and there is no registration_check_status function. I should have a working patch soon.
Comment #7
jpontani CreditAttribution: jpontani commentedCommitted in 68a3dbc. Check it out and let me know if it works for you. I added a custom validation handler to the add_to_cart form, so that if the product being added to the cart is not available for registration, an error message shows up saying the product is unavailable, and the product is never added to the cart. It also disables the product selection and Add to Cart button if all products on the node are not available for registration.
Comment #8
jpontani CreditAttribution: jpontani commentedLatest commit (414b544) should have all the right changes. Had to change the submit handler for the display nodes to go back to custom since the registration submit handler force redirects.
Posted an issue at #1484036: Don't force redirect on registration settings submit, or allow override pertaining to this issue. If that submit handler removes the forced redirect, I will go back to using that submit handler, otherwise I can't since I have to save registration settings for multiple products.
Comment #9
jpontani CreditAttribution: jpontani commentedLatest commit 637064f added some more registration_status calls where I forgot to add some.
I still can't use Registration's submit handlers as it forces redirects still. Going to mark as fixed for now.