From 1b6f98c7cb3a55957d4ada092d9766b3a52cc6a0 Mon Sep 17 00:00:00 2001 From: mattbk Date: Tue, 6 Oct 2015 19:53:50 -0500 Subject: [PATCH] Added a handler for the third attribute --- .../uc_views_attribute.info | 1 + .../views/uc_views_attribute.views.inc | 13 ++++++++ ...andler_field_order_product_attribute03.inc | 32 +++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 uc_views/uc_views_attribute/views/uc_views_attribute_handler_field_order_product_attribute03.inc diff --git a/uc_views/uc_views_attribute/uc_views_attribute.info b/uc_views/uc_views_attribute/uc_views_attribute.info index f048e1e..ffe7cf7 100644 --- a/uc_views/uc_views_attribute/uc_views_attribute.info +++ b/uc_views/uc_views_attribute/uc_views_attribute.info @@ -17,4 +17,5 @@ files[] = views/uc_views_handler_field_attributes.inc files[] = views/uc_views_attribute_handler_field_order_product_attribute01.inc files[] = views/uc_views_attribute_handler_field_order_product_attribute02.inc +files[] = views/uc_views_attribute_handler_field_order_product_attribute03.inc diff --git a/uc_views/uc_views_attribute/views/uc_views_attribute.views.inc b/uc_views/uc_views_attribute/views/uc_views_attribute.views.inc index 35af658..6c130b0 100644 --- a/uc_views/uc_views_attribute/views/uc_views_attribute.views.inc +++ b/uc_views/uc_views_attribute/views/uc_views_attribute.views.inc @@ -125,7 +125,20 @@ foreach($result as $row) { 'handler' => 'uc_views_attribute_handler_field_order_product_attribute02', ), ); + + // Add viewhandler for uc_order_product attributes: Attribute 03 + $data['uc_order_products']['attributes03'] = array( + 'title' => t('Product attribute 03'), + 'help' => t('The third attribute selection for the ordered product.'), + 'group' => t('Ubercart order product'), + 'field' => array( + 'table' => 'uc_order_products', + 'real field' => 'data', + 'handler' => 'uc_views_attribute_handler_field_order_product_attribute03', + ), + ); + return $data; } diff --git a/uc_views/uc_views_attribute/views/uc_views_attribute_handler_field_order_product_attribute03.inc b/uc_views/uc_views_attribute/views/uc_views_attribute_handler_field_order_product_attribute03.inc new file mode 100644 index 0000000..bb80eb6 --- /dev/null +++ b/uc_views/uc_views_attribute/views/uc_views_attribute_handler_field_order_product_attribute03.inc @@ -0,0 +1,32 @@ +{$this->field_alias}); + $result = ""; + if (is_array($data['attributes'])) { + $rows = array(); + foreach ($data['attributes'] as $attribute => $option) { + $rows[] = t('@option', array('@attribute' => $attribute, '@option' => implode(', ', (array) $option))); + if (count($rows)) { + //Grab the value for the third attribute. + $result = $rows[2]; + } + } + } + return $result; + } +}