function uc_attribute_condition_ordered_product_option in Ubercart 5
Same name and namespace in other branches
- 6.2 uc_attribute/uc_attribute.ca.inc \uc_attribute_condition_ordered_product_option()
- 7.3 uc_attribute/uc_attribute.rules.inc \uc_attribute_condition_ordered_product_option()
File
- uc_attribute/
uc_attribute_workflow.inc, line 23 - Workflow-ng file for Ubercart attributes.
Code
function uc_attribute_condition_ordered_product_option($order, $settings) {
$result = FALSE;
foreach ($order->products as $product) {
if (!isset($product->data['attributes'])) {
continue;
}
$attributes = $product->data['attributes'];
// Once the order is made, the attribute data is changed to just the names.
// If we can't find it by ID, check the names.
if (is_int(key($attributes))) {
if (in_array($settings['attribute_option'], $attributes)) {
$result = TRUE;
break;
}
}
else {
// Load the attribute data once, only if we need it.
if (!isset($option)) {
if ($option = uc_attribute_option_load($settings['attribute_option'])) {
$attribute = uc_attribute_load($option->aid);
}
}
if ($attribute) {
if (isset($attributes[$attribute->name]) && $attributes[$attribute->name] == $option->name) {
$result = TRUE;
break;
}
}
}
}
return $result;
}