Advertisement
Guest User

Untitled

a guest
May 15th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.79 KB | None | 0 0
  1. <div id="real-tb-attributes" class="real-tab-content">
  2.  
  3. <?php $cats = get_product_cats($post->ID);
  4.    
  5.     if ($cats) {
  6.         $cat = $cats[62];
  7.         $cat_id = $cat->term_id;
  8.     }  ?>
  9.  
  10.     <?php if ($cat) {
  11.         // get cat groups
  12.         $groups = get_real_cat_groups($cat_id);
  13.         $groups_data = get_real_groups_data();
  14.         $attrs_data = get_real_attributes_data();
  15.  
  16.         if (real_is_array($groups)) {
  17.             $count = 0; ?>
  18.             <ul class="real-data-pils">
  19.                 <?php foreach ($groups as $group) { ?>
  20.                     <li data-pil="#real-pil-<?php echo $group; ?>"<?php if ($count == 0) echo ' class="active"'; ?>><?php echo $groups_data[$group]['name']; ?></li>
  21.                     <?php $count++;
  22.                 } ?>
  23.             </ul>
  24.  
  25.             <div class="real-pil-container">
  26.                 <?php $count = 0;
  27.                 foreach ($groups as $group) {
  28.                     $group_data = $groups_data[$group];
  29.                     $group_values = get_real_product_attributes($post->ID, $group); ?>
  30.                     <div id="real-pil-<?php echo $group; ?>" class="real-pil-content<?php if ($count == 0) echo ' active'; ?>">
  31.                         <?php if ($group_data['attrs']) { ?>
  32.                             <div class="real-group-inputs">
  33.                                 <ul class="real-input-filelds">
  34.                                     <?php if (real_is_array($group_data['attrs'])) {
  35.                                         foreach ($group_data['attrs'] as $attr_id) {
  36.                                             $attr = $attrs_data[$attr_id];
  37.                                             $attr_val = (isset($group_values[$attr_id])) ? $group_values[$attr_id] : ''; ?>
  38.                                             <li>
  39.                                                 <div class="real-col-1">
  40.                                                     <label for="attr-input-<?php echo $attr_id; ?>"><?php echo $attr['name']; ?></label>
  41.                                                 </div>
  42.                                                 <div class="real-col-5">
  43.                                                     <?php // switch the input types
  44.                                                     switch ($attr['meta']['type']) {
  45.                                                         case 'text' :
  46.                                                             // make text input field
  47.                                                             echo '<input type="text" id="attr-input-' .$attr_id .'" name="real-attr[' .$group .'][' .$attr_id .']" class="real-text-input" value="' .$attr_val .'" />';
  48.                                                         break;
  49.  
  50.                                                         case 'check' :
  51.                                                             // make checkbox input field
  52.                                                             echo '<input type="hidden" name="real-attr[' .$group .'][' .$attr_id .']" value="No" />';
  53.                                                             echo '<input type="checkbox" id="attr-input-' .$attr_id .'" name="real-attr[' .$group .'][' .$attr_id .']" class="real-checkbox" value="Yes"' .(($attr_val == 'Yes') ? ' checked="checked"' : '') .' />';
  54.                                                         break;
  55.  
  56.                                                         case 'date' :
  57.                                                             // make date input field
  58.                                                             echo '<input type="text" id="attr-input-' .$attr_id .'" name="real-attr[' .$group .'][' .$attr_id .']" class="real-date-input real-text-input" value="' .$attr_val .'" />';
  59.                                                         break;
  60.  
  61.                                                         case 'textarea' :
  62.                                                             // make textarea input field
  63.                                                             echo '<textarea id="attr-input-' .$attr_id .'" name="real-attr[' .$group .'][' .$attr_id .']" class="real-textarea" rows="4">' .$attr_val .'</textarea>';
  64.                                                         break;
  65.  
  66.                                                         case 'select' :
  67.                                                             // make select box
  68.                                                             echo '<div class="real-select-label"><select id="attr-input-' .$attr_id .'" name="real-attr[' .$group .'][' .$attr_id .']" class="real-select-box">';
  69.                                                             foreach ($attr['meta']['options'] as $option) {
  70.                                                                 echo '<option value="' .$option .'"' .(($option == $attr_val) ? ' selected="selected"' : '') .'>' .$option .'</option>';
  71.                                                             }
  72.                                                             echo '</select></div>';
  73.                                                         break;
  74.  
  75.                                                         case 'mselect' :
  76.                                                             // make multi select box
  77.                                                             $attr_val = (array) $attr_val;
  78.                                                             echo '<select id="attr-input-' .$attr_id .'" name="real-attr[' .$group .'][' .$attr_id .']" size="' .count($attr['meta']['options']) .'" class="real-select-box" multiple>';
  79.                                                             foreach ($attr['meta']['options'] as $option) {
  80.                                                                 echo '<option value="' .$option .'"' .((in_array($option, $attr_val)) ? ' selected="selected"' : '') .'>' .$option .'</option>';
  81.                                                             }
  82.                                                             echo '</select>';
  83.                                                         break;
  84.                                                     } ?>
  85.                                                 </div>
  86.                                             </li>
  87.                                         <?php }
  88.                                     } ?>
  89.                                 </ul>
  90.                             </div>
  91.                         <?php } ?>
  92.                     </div>
  93.                     <?php $count++;
  94.                 } ?>
  95.             </div>
  96.         <?php } else { ?>
  97.             <p><?php _e('No Groups found for this category, you may add groups by editing category.', 'real-text'); ?></p>
  98.         <?php }
  99.     } else { ?>
  100.         <p><?php _e('Please select a Category to continue.', 'real-text'); ?></p>
  101.     <?php } ?>
  102. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement