I am using the Commerce node checkout module (https://www.drupal.org/project/commerce_node_checkout). How would I add the form product array form to appear only when the expiration is greater than the current date and time.

function commerce_node_checkout_expire_relist_form($form, &$form_state, $node, $add_expiration = TRUE) {
  $form['#node'] = $node;

  // Add the expiration date and message, if desired
  if ($add_expiration) {
    // @todo: Add a message about how buying adds to the expiration time?
    $expiration = commerce_node_checkout_expire_get_node_expiration($node);
    $form['expiration'] = array(
      '#type' => 'item',
      '#title' => ($expiration > REQUEST_TIME) ? t('This item is promoted until:') : t('This Business is listed but not promoted. Select a promotion below'),
      '#markup' => format_date($expiration, 'long'),

  // Add the product selection/ want to hide if node sticky or expiration > today
  $form['product'] = array(
    '#type' => 'commerce_node_checkout',
    '#node_type' => $node->type,

  // AJAX submit button
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Add to cart'),
    '#ajax' => array(
      'callback' => 'commerce_node_checkout_expire_relist_form_ajax',
      'wrapper' => str_replace('_', '-', $form_state['build_info']['form_id']),
      'method' => 'html',
      'effect' => 'fade',

  return $form;

Any pointers would be very welcome.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.