function uc_coupon_purchase_feature_form in Ubercart Discount Coupons 5
Same name and namespace in other branches
- 6 uc_coupon_purchase/uc_coupon_purchase.module \uc_coupon_purchase_feature_form()
- 7.3 uc_coupon_purchase/uc_coupon_purchase.module \uc_coupon_purchase_feature_form()
- 7.2 uc_coupon_purchase/uc_coupon_purchase.module \uc_coupon_purchase_feature_form()
Form builder for hook_product_feature().
1 string reference to 'uc_coupon_purchase_feature_form'
- uc_coupon_purchase_product_feature in uc_coupon_purchase/
uc_coupon_purchase.module - Implementation of hook_product_feature().
File
- uc_coupon_purchase/
uc_coupon_purchase.module, line 43
Code
function uc_coupon_purchase_feature_form($node, $feature) {
$models = array(
NULL => t('Any'),
$node->model => $node->model,
);
if (module_exists('uc_attribute')) {
$adjustments = db_query("SELECT model FROM {uc_product_adjustments} WHERE nid = %d", $node->nid);
while ($adjustment = db_fetch_object($adjustments)) {
if (!in_array($adjustment->model, $models)) {
$models[$adjustment->model] = $adjustment->model;
}
}
}
if (!empty($feature)) {
$data = db_fetch_object(db_query("SELECT * FROM {uc_coupon_purchase} WHERE pfid = %d", $feature['pfid']));
$form['pfid'] = array(
'#type' => 'value',
'#value' => $feature['pfid'],
);
}
else {
$data = new stdClass();
}
$coupons = array();
$result = db_query("SELECT cid, name, code FROM {uc_coupons}");
while ($coupon = db_fetch_object($result)) {
$coupons[$coupon->cid] = $coupon->name . ' (' . $coupon->code . ')';
}
$form['title'] = array(
'#type' => 'markup',
'#value' => '<h2>' . t('Coupon creation') . '</h2>',
);
$form['nid'] = array(
'#type' => 'value',
'#value' => $node->nid,
);
$form['model'] = array(
'#type' => 'select',
'#title' => t('Model/SKU'),
'#default_value' => $data->model,
'#description' => t('Select the model/SKU of the product that cause a coupon to be created.'),
'#options' => $models,
);
$form['base_cid'] = array(
'#type' => 'select',
'#title' => t('Base coupon'),
'#default_value' => $data->base_cid,
'#description' => t('Select the coupon that will be cloned and activated when a user purchases this product.'),
'#options' => $coupons,
);
return uc_product_feature_form($form);
}