If a Registration has a scheduled open/close date, and the closed date has passed (or it is not Enabled for accepting registrations) the Field should not display on the bundle it is attached to.

For example:

I have a test event that had a open/close date in the past, yet when viewing as a regular user, I could see registrations tied on the display, but it really should not show and instead show just a message about registrations are closed.

I was looking for a simple way to do this but I could not find a way in the admin.

Comments

jpontani’s picture

Status: Active » Postponed (maintainer needs more info)

Is this happening only when using Commerce Registration?

What kind of setup do you have in terms of fields and where they are? Is the registration field attached to a Commerce Product or is this only happening when the registration field is on a node?

kevinquillen’s picture

Yes, using Commerce Registration to take registrations to turn into orders. A content type (node) has a Product Reference field back to the registration products, which displays the Add to Cart form.

kevinquillen’s picture

What is a good way to grab the registration properties (enable, open/closed) from a product reference (Product type - Registration) from a Product?

kevinquillen’s picture

Title: Registration Form Display » Creating a backend order is not permitted due to Required Fields on Registration entity
Component: User interface » Code
kevinquillen’s picture

Title: Creating a backend order is not permitted due to Required Fields on Registration entity » Registration Entity Settings and 'Add to Cart' Form

My bad- changed the wrong issue title. Too many tabs open.

kevinquillen’s picture

This is basically what I did to get around this.

I made a form_alter call that loaded the first product found in the registration entity list in the form (for my case, each one's setting is uniform per registration) then loaded its settings with registration_entity_settings().

Then I looked at status, open, and close property of the entity:


if ($registration_settings['status'] != '1') {
    // form is disabled
    unset($form['product_id']);
    unset($form['submit']);
    $form['disabled'] = array(
      '#type' => 'item',
      '#markup' => '<p>Registrations are disabled for this tournament.</p>',
    );
  }

  $open = strtotime($registration_settings['open']);
  $close = strtotime($registration_settings['close']);

  if ($open > time()) {
    // registrations are not open yet, hide the form, show an opening message
    unset($form['product_id']);
    unset($form['submit']);
    $form['open_message'] = array(
      '#type' => 'item',
      '#markup' => '<p>Registrations open on ' . date('m/d/Y', $open) . ' at ' . date('h:m a', $open) . '.</p>',
    );
  }

  if ($close < time()) {
    // registrations are closed
    unset($form['open_message']);
    unset($form['product_id']);
    unset($form['submit']);
    $form['close_message'] = array(
      '#type' => 'item',
      '#markup' => '<p>Registrations are closed.</p>',
    );
  } else {
    $form['close_message'] = array(
      '#type' => 'item',
      '#weight' => -10,
      '#markup' => '<p>The deadline to register is ' . date('m/d/Y', $close) . ' at ' . date('h:m a', $close) . '.</p>',
    );
  }

I did not see this in the UI or code anywhere. It would be nice if Registration did not return a product which to register for if the settings are not met, then if the Add to Cart select is empty, simply replaced with "Registrations are closed." instead of showing a form.

There will be a case when the registration settings don't match for a commerce registration, such as the dates for each, in which that would be necessary.

jpontani’s picture

Assigned: Unassigned » jpontani
Category: support » feature
Status: Postponed (maintainer needs more info) » Needs work

This is something I can add in.

jpontani’s picture

Status: Needs work » Fixed

Added this in the latest dev branch.

Status: Fixed » Closed (fixed)

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

TravisJohnston’s picture

Version: 7.x-2.x-dev » 7.x-2.0-beta5
Status: Closed (fixed) » Active

Still not working. Its a good thing I was paying attention to it too because we had registrations closing at 9/11/2013 at 5:00pm and I noticed at 5:30 that they were all still enabled... Plus there are some cases when you uncheck the Enable button, the Add to Cart button still shows...

TravisJohnston’s picture

Does the open/closed date rely on cron to update?? Just a thought I had

blacklabel_tom’s picture

Issue summary: View changes

Hi Travis,

Was this on the beta5 version of the module or latest dev?

Cheers

Tom

blacklabel_tom’s picture

Status: Active » Postponed (maintainer needs more info)
TravisJohnston’s picture

On the beta, I came up with a work around though. I have a date field on the product called "Register By" (field_register_by) that I have the content editor fill in, then I have a rule scheduled to run nightly that disables the product (that has the attached registration) at midnight every night and sends me an email.

I haven't done any further testing with the newer versions since I have enabled this setup.

blacklabel_tom’s picture

Hi Travis,

Thanks for the info, I'll take another look at this case.

Cheers

Tom

Dadaisme’s picture

Hi!

Anything new for this problem?

Thx.