diff --git a/uc_attribute/uc_attribute.rules.inc b/uc_attribute/uc_attribute.rules.inc index f121ecd..672b87f 100644 --- a/uc_attribute/uc_attribute.rules.inc +++ b/uc_attribute/uc_attribute.rules.inc @@ -26,48 +26,28 @@ function uc_attribute_rules_condition_info() { } /** - * Returns TRUE if a product in the given order has the selected option. + * Returns TRUE if the product from a given order has the selected option. * * @see uc_attribute_condition_ordered_product_option_form() */ -function uc_attribute_condition_ordered_product_option($order) { - $result = FALSE; - - $match = unserialize($settings['attribute_option']); - - foreach ($order->products as $product) { - if (!isset($product->data['attributes'])) { - continue; - } +function uc_attribute_condition_ordered_product_option($product, $option) { + if (empty($product->data['attributes'])) { + return FALSE; + } - $attributes = $product->data['attributes']; + $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); - } - } + // Once the order is made, the attribute data is changed to just the names. + // Load the attribute data once, only if we need it. + if ($option = uc_attribute_option_load($option)) { + $attribute = uc_attribute_load($option->aid); + } - if ($attribute) { - if (isset($attributes[$attribute->name]) && $attributes[$attribute->name] == $option->name) { - $result = TRUE; - break; - } - } - } + if (isset($attribute) && isset($attributes[$attribute->name]) && $attributes[$attribute->name][0] == $option->name) { + return TRUE; } - return $result; + return FALSE; } /** diff --git a/uc_order/uc_order.info.inc b/uc_order/uc_order.info.inc index 05cf029..2d5064c 100644 --- a/uc_order/uc_order.info.inc +++ b/uc_order/uc_order.info.inc @@ -159,8 +159,6 @@ function uc_order_entity_property_info() { 'type' => 'list', 'label' => t('Products'), 'description' => t('The products that have been ordered.'), - 'getter callback' => 'uc_order_get_properties', - 'setter callback' => 'uc_order_set_properties', 'setter permission' => 'edit orders', 'clear' => array('order_total'), ),