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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mrfelton’s picture

Status: Active » Needs review
FileSize
4.18 KB

Attached 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.

mrfelton’s picture

Attached 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.

mrfelton’s picture

I'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.

mrfelton’s picture

Updated again, this adds an implementation of hook_registration_status_alter() which is used to enable/disable the product based on the schedule.

mrfelton’s picture

Patch updated to remove trailing whitespace.

jpontani’s picture

Status: Needs review » Needs work

Setting 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.

jpontani’s picture

Status: Needs work » Needs review

Committed 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.

jpontani’s picture

Latest 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.

jpontani’s picture

Status: Needs review » Fixed

Latest 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.

Status: Fixed » Closed (fixed)

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