Guest User

Untitled

a guest
Jul 4th, 2013
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.70 KB | None | 0 0
  1. <?php
  2.  
  3. function hikashop_characteristics_html(&$element, &$params, &$obj) {
  4.     switch ($params->get('characteristic_display')) {
  5.         case 'table':
  6.             if (count($obj->characteristics) == 2) {
  7.                 $html = '';
  8.                 $firstCharacteristic = reset($obj->characteristics);
  9.                 $secondCharacteristic = end($obj->characteristics);
  10.                 $html.= '<table class="hikashop_product_characteristic_chooser"><tr><td></td>';
  11.                 if (empty($secondCharacteristic->values)) {
  12.                    
  13.                 } else {
  14.                     foreach ($secondCharacteristic->values as $value) {
  15.                         $html.='<td>' . $value->characteristic_value . '</td>';
  16.                     }
  17.                 }
  18.                 $html.='</tr>';
  19.                 $obj->options = ' onclick="return hikashopUpdateVariantData(this.value);"';
  20.                 $size = 0;
  21.                 if (!empty($firstCharacteristic->values)) {
  22.                     foreach ($firstCharacteristic->values as $value) {
  23.                         $html.='<tr><td style="text-align:right">' . $value->characteristic_value . '</td>';
  24.                         if (strlen($value->characteristic_value) > $size)
  25.                             $size = strlen($value->characteristic_value);
  26.                         if (!empty($secondCharacteristic->values)) {
  27.                             foreach ($secondCharacteristic->values as $value2) {
  28.                                 $class = '';
  29.                                 $classspan = '';
  30.                                 foreach ($element->variants as $k => $variant) {
  31.                                     $char1 = false;
  32.                                     $char2 = false;
  33.                                     foreach ($variant->characteristics as $variantCharacteristic) {
  34.                                         if ($variantCharacteristic->characteristic_id == $value->characteristic_id) {
  35.                                             $char1 = true;
  36.                                         } elseif ($variantCharacteristic->characteristic_id == $value2->characteristic_id) {
  37.                                             $char2 = true;
  38.                                         }
  39.                                         if ($char1 && $char2) {
  40.                                             if (!$variant->product_published || $variant->product_quantity == 0) {
  41.                                                 $class = ' hikashop_product_variant_out_of_stock';
  42.                                                 $classspan = ' hikashop_product_variant_out_of_stock_span';
  43.                                             }
  44.                                             break 2;
  45.                                         }
  46.                                     }
  47.                                 }
  48.                                 $name = '_' . $value->characteristic_id . '_' . $value2->characteristic_id;
  49.                                 $radio = "\n\t<span class=\"hikashop_product_characteristic_span" . $classspan . "\"><input type=\"radio\" class=\"hikashop_product_characteristic" . $class . "\" name=\"hikashop_product_characteristic\" id=\"hikashop_product_characteristic" . $name . "\" value=\"" . $name . "\" " . $obj->options;
  50.                                 if ($obj->characteristics[$value->characteristic_parent_id]->default->characteristic_id == $value->characteristic_id && !empty($obj->characteristics[$value2->characteristic_parent_id]->default->characteristic_id) && $obj->characteristics[$value2->characteristic_parent_id]->default->characteristic_id == $value2->characteristic_id) {
  51.                                     $radio.=' checked';
  52.                                 }
  53.                                 $radio.=" /></span>";
  54.                                 $html.='<td>' . $radio . '</td>';
  55.                             }
  56.                         }
  57.                         $html.='</tr>';
  58.                     }
  59.                 }
  60.                 $html.='</table>';
  61.                 if ($params->get('characteristic_display_text')) {
  62.                     $space = '';
  63.                     for ($i = 0; $i <= $size; $i++) {
  64.                         $space.='&nbsp;&nbsp;';
  65.                     }
  66.                     $html = '<table class="hikashop_product_characteristic_chooser"><tr><td></td/><td>' . $space . $secondCharacteristic->characteristic_value . '</td></tr><tr><td>' . $firstCharacteristic->characteristic_value . '</td><td>' . $html . '</td></table>';
  67.                 }
  68.                 break;
  69.             }
  70.         default:
  71.         case 'radio':
  72.         case 'dropdown':
  73.             $main_html = '<table class="hikashop_product_characteristics_table">';
  74.             $config = & hikashop_config();
  75.             foreach ($obj->characteristics as $characteristic) {
  76.                 $main_html.='<tr>';
  77.                 $values = array();
  78.                 if (!empty($characteristic->values)) {
  79.                     foreach ($characteristic->values as $k => $value) {
  80.                         if (!$config->get('show_out_of_stock')) {
  81.                             $hasQuantity = false;
  82.                             foreach ($element->variants as $variant) {
  83.                                 foreach ($variant->characteristics as $variantCharacteristic) {
  84.                                     if ($variantCharacteristic->characteristic_id == $value->characteristic_id) {
  85.                                         if ($variant->product_quantity != 0) {
  86.                                             $hasQuantity = true;
  87.                                         }
  88.                                     }
  89.                                 }
  90.                             }
  91.                             if (!$hasQuantity)
  92.                                 continue;
  93.                         }
  94.                         $values[$k] = '<img src="/media/exo_colors/' . $value->characteristic_value . '.png" id=' . $value->characteristic_value . ' />';
  95.                     }
  96.                 }
  97.                 $html = $obj->display($characteristic->characteristic_id, @$characteristic->default->characteristic_id, $values, $characteristic->characteristic_value, $params->get('characteristic_display'));
  98.                 if ($params->get('characteristic_display_text')) {
  99.                     $html = $characteristic->characteristic_value . '</td><td>' . $html;
  100.                 }
  101.                 $main_html.='<td>' . $html . '</td></tr>';
  102.             }
  103.             $main_html.='</table>';
  104.             $html = $main_html;
  105.             break;
  106.     }
  107.  
  108.     $html.='
  109.         <noscript>
  110.             <input type="submit" class="button" name="characteristic" value="' . JText::_('REFRESH_INFORMATION') . '"/>
  111.         </noscript>';
  112.     return $html;
  113. }
  114.  
  115. ?>
Advertisement
Add Comment
Please, Sign In to add comment