You are here

function uc_varprice_feature_form in UC Variable Price 7

Same name and namespace in other branches
  1. 6 uc_varprice.module \uc_varprice_feature_form()

Settings form for individual Variable Price product features.

1 string reference to 'uc_varprice_feature_form'
uc_varprice_uc_product_feature in ./uc_varprice.module
Implements hook_uc_product_feature().

File

./uc_varprice.module, line 267
Defines a product feature to turn any product into a variable priced product.

Code

function uc_varprice_feature_form($form, &$form_state, $node, $feature) {

  // Add some helper JS to the form.
  drupal_add_js(drupal_get_path('module', 'uc_varprice') . '/uc_varprice.js');

  // Load the Variable Price data specific to this product.
  if (!empty($feature)) {
    $varprice_feature = db_query('SELECT * FROM {uc_varprice_products} WHERE pfid = :pfid', array(
      ':pfid' => $feature['pfid'],
    ))
      ->fetchObject();
  }
  else {
    $varprice_feature = new stdClass();
    $varprice_feature->pfid = NULL;
    $varprice_feature->price_default = variable_get('uc_varprice_global_default', '0');
    $varprice_feature->price_minimum = '';
    $varprice_feature->price_maximum = '';
    $varprice_feature->add_to_cart_title = t('Add to cart');
    $varprice_feature->amount_title = t('Amount');
  }
  $form['nid'] = array(
    '#type' => 'value',
    '#value' => $node->nid,
  );
  $form['pfid'] = array(
    '#type' => 'value',
    '#value' => $varprice_feature ? $varprice_feature->pfid : '',
  );
  $form += _uc_varprice_feature_form($varprice_feature);
  return $form;
}