Why not use CCK date fields instead of using a custom built solution? An option in the Product Content Type settings could ask a user to select which date field (created first under manage fields) to use as the LTO datefield. This would not only already be integrated with views, but would give a user much more flexibility in what he could build.

Thoughts?

Comments

JGonzalez’s picture

Note - The functionality I'm talking about is similar to how Ubercart does for the product image
"Product image field:" -> select a cck image field.

JGonzalez’s picture

Something along the lines of this, and removing the custom datefield all-together. Would provide a patch to do this but I suck at writing stuff back to the db :-\. Only have gotten this far.

/**
 * Implementation of hook_form_FORM_ID_alter().
 */
function uc_lto_form_node_type_form_alter(&$form) {

  if (uc_product_is_product($form['#node_type']->type)) {
 
 
   // date field
    $fields = content_types($type->type);
    $fields = (array)$fields['product']['fields'];
    $options = array('' => t('None'));
    foreach ($fields as $field_name => $field) {
      if (strpos($field['widget']['type'], 'date') !== FALSE) {
        $options[$field_name] = $field['widget']['label'];
      }
    }
    $form['uc_lto'] = array(
      '#type' => 'fieldset',
      '#title' => t('Limited time offer settings'),
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
      '#weight' => 2,	
	   'uc_lto_lto_datefield' => array(
      '#type' => 'select',
      '#title' => t('Product date field'),
      '#default_value' => variable_get('uc_lto_lto_datefield_'. $type->type, NULL),
      '#options' => $options,
      '#description' => t('The selected field will be used on Ubercart pages to represent the products of this content type.'),
      '#weight' => -4,
    ),	
      'uc_lto_overrides_desc' => array(
          '#type' => 'markup',
          '#weight' => -8,
          '#value' => t('<p>Check the box below to have new products created under this content type (product class) be a limited time offer product by default.</p> <p>The "Display Time of expiration" displays the date and time a product is no longer available for purchase.  The "Display time left w/o active countdown" and the "Active javascript countdown" options both display the time left (1 day, 1 hour, etc.).  One would display the time left when a page is loaded or refreshed while the other is an active "countdown clock".'),
      ),
      'uc_lto_lto_type' => array(
        '#type' => 'select',
        '#title' => t('Activate limited time offer functionality on this content type as default'),
        '#description' => t('New products created under this product class (product content type) will use this setting by default when a new product is created.  Different settings can be used on a specific product under this product class by making a different selection when creating or editing a product.'),
        '#default_value' => variable_get('uc_lto_lto_type_' . $form['#node_type']->type, FALSE),
        '#options' => array(
          '0' => 'Not Limited Time Offer',
          '3' => 'LTO - Display time of expiration',
          '6' => 'LTO - Display time left w/o active countdown',
          '9' => 'LTO - Active javascript countdown',
        ),
        '#weight' => 0,
      ),
    );
  }
}





BManuel’s picture

Subscribing

WebNewCastle’s picture

Hi,

Thank you very for the suggestion and contribution. I apologize for the delay acknowledging this. It's been a busy month, but I am going to try to schedule time to take a closer look very soon. And I think this is something I should review further before moving forward with the process of Views integration - since that process would change if this is included.

- Matt

g.k’s picture

Subscribing

bturoque’s picture

Subscribing

wallbay1’s picture

sub

avpaderno’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

I am closing this issue, as Drupal 6 is now not supported.