function uc_cart_condition_product_class in Ubercart 6.2
Same name and namespace in other branches
- 5 uc_cart/uc_cart_workflow.inc \uc_cart_condition_product_class()
Check that an order has a product of the selected class.
See also
uc_cart_condition_product_class_form()
1 string reference to 'uc_cart_condition_product_class'
- uc_cart_ca_condition in uc_cart/
uc_cart.ca.inc - Implements hook_ca_condition().
File
- uc_cart/
uc_cart.ca.inc, line 122 - This file contains the Conditional Actions hooks and functions necessary to make the cart related entity, conditions, events, and actions work.
Code
function uc_cart_condition_product_class($order, $settings) {
$result = FALSE;
$types = array();
foreach ($order->products as $product) {
// Ignore "blank line" custom products.
if ($product->nid) {
// Cache product types to avoid extra queries.
if (!isset($types[$product->nid])) {
if (isset($product->type)) {
$types[$product->nid] = $product->type;
}
else {
$types[$product->nid] = db_result(db_query("SELECT type FROM {node} WHERE nid = %d", $product->nid));
}
}
if ($types[$product->nid] == $settings['class']) {
$result = TRUE;
break;
}
}
}
return $result;
}