function uc_varprice_uc_add_to_cart in UC Variable Price 7
Implements hook_uc_add_to_cart().
File
- ./
uc_varprice.module, line 186 - Defines a product feature to turn any product into a variable priced product.
Code
function uc_varprice_uc_add_to_cart($nid, $qty, $data) {
$result = array();
// If there is Variable Price data for this product...
if (isset($data['varprice'])) {
$message = '';
// Load the product feature data.
$vp_data = uc_varprice_product_load($nid);
// Fail if the customer failed to enter a price.
if (empty($data['varprice']) || $data['varprice'] == 0) {
$message = t('You must specify a price.');
}
elseif (!empty($vp_data->price_minimum) && $data['varprice'] < $vp_data->price_minimum) {
$message = t('You must specify an amount greater than or equal to @price.', array(
'@price' => uc_currency_format($vp_data->price_minimum),
));
}
elseif (!empty($vp_data->price_maximum) && $data['varprice'] > $vp_data->price_maximum) {
$message = t('You must specify an amount less than or equal to @price.', array(
'@price' => uc_currency_format($vp_data->price_maximum),
));
}
// If an error message was set, return the failure notification.
if (!empty($message)) {
return array(
array(
'success' => FALSE,
'message' => $message,
'silent' => FALSE,
),
);
}
}
}