function uc_attribute_condition_ordered_product_option in Ubercart 7.3
Same name and namespace in other branches
- 5 uc_attribute/uc_attribute_workflow.inc \uc_attribute_condition_ordered_product_option()
- 6.2 uc_attribute/uc_attribute.ca.inc \uc_attribute_condition_ordered_product_option()
Returns TRUE if a product in the given order has the selected option.
See also
uc_attribute_condition_ordered_product_option_form()
1 string reference to 'uc_attribute_condition_ordered_product_option'
- uc_attribute_rules_condition_info in uc_attribute/
uc_attribute.rules.inc - Implements hook_rules_condition_info().
File
- uc_attribute/
uc_attribute.rules.inc, line 33 - Rules hooks for Ubercart attributes.
Code
function uc_attribute_condition_ordered_product_option($order, $oid) {
$option = uc_attribute_option_load($oid);
$attribute = uc_attribute_load($option->aid);
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 (isset($attributes[$oid])) {
return TRUE;
}
}
elseif (isset($attributes[$attribute->name][$oid])) {
return TRUE;
}
}
return FALSE;
}