You are here

function uc_coupon_purchase_attribute_property_getter in Ubercart Discount Coupons 7.3

1 string reference to 'uc_coupon_purchase_attribute_property_getter'
uc_coupon_purchase_entity_property_info_alter in uc_coupon_purchase/uc_coupon_purchase.module

File

uc_coupon_purchase/uc_coupon_purchase.module, line 589

Code

function uc_coupon_purchase_attribute_property_getter($product, $options, $name, $type, $info) {
  if (!empty($product->data['attributes'])) {
    if ($type == 'uc_cart_item') {
      $product = clone $product;
      uc_attribute_uc_order_product_alter($product, NULL);
    }
    $attributes = uc_attribute_load_product_attributes($product->nid);
    $key = FALSE;
    foreach ($attributes as $aid => $attribute) {
      if ($attribute->name == $name) {
        $key = $attribute->label;
        break;
      }
    }
    return $key && !empty($product->data['attributes'][$key]) ? implode(',', $product->data['attributes'][$key]) : NULL;
  }
}