function insertOrdersProductPreProc(&$params, &$reference)
 {
     error_log("insertOrdersProductPreProc - begin");
     $order_id = $params['insertArray']['orders_id'];
     $cart_product_item = $params['value'];
     $product_id = $cart_product_item['products_id'];
     $variant_id = $cart_product_item['variant_id'];
     // Get variant's details from the db
     $qry_res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('v.variant_price, v.variant_sku', 'tx_msvariants_domain_model_variants v', 'v.variant_id=' . $variant_id . ' and v.product_id=' . $product_id);
     if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry_res) != 1) {
         // TODO this should never happen - raise exception?
         return;
     }
     $variant_data = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry_res);
     // Insert variant details about the order into the db
     $insert_array = array('order_id' => $order_id, 'product_id' => $product_id, 'variant_id' => $variant_id, 'price' => $variant_data['variant_price'], 'quantity' => $cart_product_item['qty'], 'sku' => $variant_data['variant_sku']);
     $res = $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_msvariants_domain_model_variantsorders', $insert_array);
     // Insert variant attributes details about the order into the db
     $qry_res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('va.attribute_id, va.option_id, va.option_value_id', 'tx_msvariants_domain_model_variantsattributes va', 'va.variant_id=' . $variant_id . ' and va.product_id=' . $product_id);
     if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry_res) <= 0) {
         // TODO this should never happen - raise exception?
         return;
     }
     while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry_res)) != false) {
         $row['option_name'] = mslib_fe::getRealNameOptions($row['option_id']);
         $row['option_value_name'] = mslib_fe::getNameOptions($row['option_value_id']);
         $insert_array = array('order_id' => $order_id, 'product_id' => $product_id, 'variant_id' => $variant_id, 'attribute_id' => $row['attribute_id'], 'option_id' => $row['option_id'], 'option_value_id' => $row['option_value_id'], 'option_name' => $row['option_name'], 'option_value_name' => $row['option_value_name']);
         $res = $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_msvariants_domain_model_variantsattributesorders', $insert_array);
     }
     // while
     error_log("insertOrdersProductPreProc - end");
 }
            $js_select2_cache_options = array();
            $js_select2_cache_values = array();
            $js_select2_cache = '
			<script type="text/javascript">
				var attributesSearchOptions=[];
				var attributesSearchValues=[];
				var attributesOptions=[];
				var attributesValues=[];' . "\n";
            if ($product['products_id']) {
                if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry_pa) > 0) {
                    $ctr = 1;
                    $options_data = array();
                    $attributes_data = array();
                    $attribute_values_class_id = array();
                    while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry_pa)) != false) {
                        $row['options_values_name'] = mslib_fe::getNameOptions($row['options_values_id']);
                        $options_data[$row['products_options_id']] = $row['products_options_name'];
                        $attributes_data[$row['products_options_id']][] = $row;
                        // js cache
                        $js_select2_cache_options[$row['products_options_id']] = 'attributesOptions[' . $row['products_options_id'] . ']={id:"' . $row['products_options_id'] . '", text:"' . htmlentities($row['products_options_name'], ENT_QUOTES) . '"}';
                        $js_select2_cache_values[$row['options_values_id']] = 'attributesValues[' . $row['options_values_id'] . ']={id:"' . $row['options_values_id'] . '", text:"' . htmlentities($row['options_values_name'], ENT_QUOTES) . '"}';
                    }
                    if (count($options_data)) {
                        $attributes_tab_block .= '<thead><tr id="product_attributes_content_row">';
                        $attributes_tab_block .= '<td colspan="5" id="products_attributes_items">';
                        foreach ($options_data as $option_id => $option_name) {
                            if (!isset($group_row_type) || $group_row_type == 'even_group_row') {
                                $group_row_type = 'odd_group_row';
                            } else {
                                $group_row_type = 'even_group_row';
                            }
 } else {
     $price_prefix = '+';
     $this->post['edit_manual_price'][$x] = str_replace('+', '', $this->post['edit_manual_price'][$x]);
 }
 if (!empty($this->post['edit_manual_option'][$x]) && !empty($this->post['edit_manual_values'][$x])) {
     $optname = $this->post['edit_manual_option'][$x];
     $optid = 0;
     $optvalname = $this->post['edit_manual_values'][$x];
     $optvalid = 0;
     if (!$this->post['is_manual_option'][$x]) {
         $optid = $this->post['edit_manual_option'][$x];
         $optname = mslib_fe::getRealNameOptions($optid);
     }
     if (!$this->post['is_manual_value'][$x]) {
         $optvalid = $this->post['edit_manual_values'][$x];
         $optvalname = mslib_fe::getNameOptions($optvalid);
     }
     $insertArray = array();
     $insertArray['orders_id'] = (int) $this->get['orders_id'];
     $insertArray['orders_products_id'] = $orders_products_id;
     $insertArray['products_options'] = $optname;
     $insertArray['products_options_values'] = $optvalname;
     $insertArray['options_values_price'] = $this->post['edit_manual_price'][$x];
     $insertArray['price_prefix'] = $price_prefix;
     $insertArray['products_options_id'] = $optid;
     $insertArray['products_options_values_id'] = $optvalid;
     $query = $GLOBALS['TYPO3_DB']->INSERTquery('tx_multishop_orders_products_attributes', $insertArray);
     $res = $GLOBALS['TYPO3_DB']->sql_query($query);
     //$sql="insert into tx_multishop_orders_products_attributes (orders_id, orders_products_id, products_options, products_options_values, options_values_price, price_prefix, attributes_values, products_options_id, products_options_values_id) values ('".$this->get['orders_id']."', '".$orders_products_id."', '".$optname."', '".$optvalname."', '".$this->post['edit_manual_price'][$x]."', '".$price_prefix."', NULL, '".$optid."', '".$optvalid."')";
     //$GLOBALS['TYPO3_DB']->sql_query($sql);
 }
 function insertProductPostHook(&$params, &$reference)
 {
     // First time product is created so variants must be generated
     // and updated with the form inputs.....
     // TODO update with the form inputs
     error_log("insertProductPostHook - begin!");
     $products_id = $params['products_id'];
     error_log("products_id: " . $params['products_id']);
     error_log("products_id: " . $products_id);
     // product Attribute
     //if (!$reference->ms['MODULES']['DISABLE_PRODUCT_VARIANTS_TAB_IN_EDITOR'])
     // Get attributes (option and options values) for product from db
     // and create variants based on attributes and insert them into db
     $output = '';
     $sql_pa = $GLOBALS['TYPO3_DB']->SELECTquery('popt.required,popt.products_options_id, popt.products_options_name, popt.listtype, patrib.*', 'tx_multishop_products_options popt, tx_multishop_products_attributes patrib', "patrib.products_id='" . $products_id . "' and popt.language_id = '0' and patrib.options_id = popt.products_options_id", '', 'patrib.sort_order_option_name, patrib.sort_order_option_value', '');
     $qry_pa = $GLOBALS['TYPO3_DB']->sql_query($sql_pa);
     if ($products_id) {
         if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry_pa) > 0) {
             $ctr = 1;
             $options_data = array();
             $attributes_data = array();
             while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry_pa)) != false) {
                 $row['options_values_name'] = mslib_fe::getNameOptions($row['options_values_id']);
                 $options_data[$row['products_options_id']] = $row['products_options_name'];
                 $attributes_data[$row['products_options_id']][] = $row;
             }
             if (count($options_data)) {
                 $num_options = count($options_data);
                 $options_ids = array_keys($options_data);
                 $counters = array_fill(0, $num_options, 0);
                 $limits = array();
                 $k = 0;
                 foreach ($options_ids as $option_id) {
                     $limits[$k] = count($attributes_data[$option_id]) - 1;
                     $k++;
                 }
                 $content_variants = '';
                 $k = 0;
                 while ($k < $num_options) {
                     if ($k == 0) {
                         $variant_name = 'Variant: ';
                         $content_options = '';
                         $markerArray = array();
                         // insert (variant_id, product_id, price, stock, sku) into db
                         $variant_row = array('variant_id' => 0, 'product_id' => $products_id, 'variant_price' => 0.0, 'variant_stock' => 0, 'variant_sku' => '');
                         $res = $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_msvariants_domain_model_variants', $variant_row);
                         error_log('variant row inserted res; ' . $res);
                         // TODO there must be a better way to set the variant_id or rename uid
                         $variant_id = $GLOBALS['TYPO3_DB']->sql_insert_id();
                         $update_array = array('variant_id' => $variant_id);
                         $res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_msvariants_domain_model_variants', 'uid=' . $variant_id, $update_array);
                         // insert list of options, values for the variant into db
                         for ($i = $num_options - 1; $i >= 0; $i--) {
                             $attribute_id = $attributes_data[$options_ids[$i]][$counters[$i]]['products_attributes_id'];
                             $option_id = $attributes_data[$options_ids[$i]][$counters[$i]]['options_id'];
                             $option_value_id = $attributes_data[$options_ids[$i]][$counters[$i]]['options_values_id'];
                             $option_name = $attributes_data[$options_ids[$i]][$counters[$i]]['products_options_name'];
                             $option_value = $attributes_data[$options_ids[$i]][$counters[$i]]['options_values_name'];
                             $variant_name .= $attributes_data[$options_ids[$i]][$counters[$i]]['options_values_name'] . " - ";
                             // insert (variant_id, ..., option, value) into db
                             $variant_option_row = array('variant_id' => $variant_id, 'product_id' => $products_id, 'attribute_id' => $attribute_id, 'option_id' => $option_id, 'option_value_id' => $option_value_id);
                             $res = $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_msvariants_domain_model_variantsattributes', $variant_option_row);
                             error_log('variantattribute row inserted res; ' . $res);
                         }
                     }
                     $counters[$k]++;
                     if ($counters[$k] > $limits[$k]) {
                         $counters[$k] = 0;
                         $k++;
                     } elseif ($k > 0) {
                         $k = 0;
                     }
                 }
             }
         }
     }
     error_log("insertProductPostHook - end");
 }
         }
         $return_data['products_used'] = $total_product;
     }
     $json_data = mslib_befe::array2json($return_data);
     echo $json_data;
     exit;
     break;
 case 'delete_options_values':
     $option_id = 0;
     $option_value_id = 0;
     list($option_id, $option_value_id) = explode(':', $this->post['data_id']);
     $return_data = array();
     $return_data['option_id'] = $option_id;
     $return_data['option_value_id'] = $option_value_id;
     $return_data['option_name'] = mslib_fe::getRealNameOptions($option_id);
     $return_data['option_value_name'] = mslib_fe::getNameOptions($option_value_id);
     $return_data['data_id'] = $this->post['data_id'];
     $return_data['delete_status'] = 'notok';
     $have_entries_in_pa_table = false;
     if ($option_value_id > 0) {
         $str = "select products_id from tx_multishop_products_attributes where options_id='" . $option_id . "' and options_values_id=" . $option_value_id;
         $qry = $GLOBALS['TYPO3_DB']->sql_query($str);
         $total_product = $GLOBALS['TYPO3_DB']->sql_num_rows($qry);
         if ($total_product > 0) {
             $ctr = 0;
             $return_data['products'] = array();
             while ($rs = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry)) {
                 $product = mslib_fe::getProduct($rs['products_id'], '', '', 1);
                 if (!empty($product['products_name'])) {
                     $return_data['products'][$ctr]['name'] = $product['products_name'];
                     $return_data['products'][$ctr]['link'] = mslib_fe::typolink($this->shop_pid . ',2003', 'tx_multishop_pi1[page_section]=edit_product&pid=' . $rs['products_id'] . '&cid=' . $product['categories_id'] . '&action=edit_product');
 function adminEditProductPreProc(&$params, &$reference)
 {
     //----------------------------------------
     // VARIANTS TAB
     //----------------------------------------
     // product Attribute
     //if (!$reference->ms['MODULES']['DISABLE_PRODUCT_VARIANTS_TAB_IN_EDITOR']) {
     $product = $params['product'];
     // Get HTML template file
     if ($reference->conf['edit_variants_tmpl_path']) {
         $template = $reference->cObj->fileResource($reference->conf['edit_variants_tmpl_path']);
     } else {
         $template = $reference->cObj->fileResource(t3lib_extMgm::siteRelPath('msvariants') . 'Templates/edit_variants.tmpl');
     }
     // Extract the subparts from the template
     $subparts = array();
     $subparts['template'] = $reference->cObj->getSubpart($template, '###TEMPLATE###');
     $subparts['item_variant'] = $reference->cObj->getSubpart($subparts['template'], '###ITEM_VARIANT###');
     $subparts['item_option'] = $reference->cObj->getSubpart($subparts['template'], '###ITEM_OPTION###');
     // Get variants from db
     $sql_pa = $GLOBALS['TYPO3_DB']->SELECTquery('vars.variant_id, vars.product_id, vars.variant_price, vars.variant_stock, vars.variant_sku, vattrs.attribute_id, vattrs.option_id, vattrs.option_value_id', 'tx_msvariants_domain_model_variants vars, tx_msvariants_domain_model_variantsattributes vattrs', "vars.product_id='" . $product['products_id'] . "' and vars.variant_id=vattrs.variant_id", '', '', '');
     $qry_pa = $GLOBALS['TYPO3_DB']->sql_query($sql_pa);
     // Generate HTML for variants tab block if there are variants
     if ($product['products_id']) {
         if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry_pa) > 0) {
             $variants_data = array();
             $variants_attributes_data = array();
             while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry_pa)) != false) {
                 if (!$variants_data[$row['variant_id']]) {
                     $variants_data[$row['variant_id']] = array('variant_id' => $row['variant_id'], 'product_id' => $row['product_id'], 'variant_price' => $row['variant_price'], 'variant_stock' => $row['variant_stock'], 'variant_sku' => $row['variant_sku']);
                 }
                 $row['option_name'] = mslib_fe::getRealNameOptions($row['option_id']);
                 $row['option_value_name'] = mslib_fe::getNameOptions($row['option_value_id']);
                 $variants_attributes_data[$row['variant_id']][] = $row;
             }
             // Generate HTML for variants
             foreach ($variants_data as $variant) {
                 $variant_name = 'Variant: ';
                 // generate HTML for variant's attributes
                 $content_options = '';
                 $markerArray = array();
                 foreach ($variants_attributes_data[$variant['variant_id']] as $variant_attribute) {
                     $markerArray['OPTION_NAME'] = $variant_attribute['option_name'];
                     $markerArray['OPTION_VALUE'] = $variant_attribute['option_value_name'];
                     $content_options .= $reference->cObj->substituteMarkerArray($subparts['item_option'], $markerArray, '###|###');
                     $variant_name .= $variant_attribute['option_value_name'] . " - ";
                 }
                 // generate HTML for variant details
                 $markerArray = array();
                 $markerArray['LABEL_VARIANT_NAME'] = $variant_name;
                 $markerArray['LABEL_PRICE'] = 'Price';
                 $markerArray['LABEL_STOCK'] = 'Stock';
                 $markerArray['LABEL_SKU'] = 'SKU';
                 $markerArray['VARIANT_ID'] = $variant['variant_id'];
                 $markerArray['PRICE'] = $variant['variant_price'];
                 $markerArray['STOCK'] = $variant['variant_stock'];
                 $markerArray['SKU'] = $variant['variant_sku'];
                 $content_item_variant = $reference->cObj->substituteMarkerArray($subparts['item_variant'], $markerArray, '###|###');
                 $content_item_variant = $reference->cObj->substituteSubpart($content_item_variant, 'ITEM_OPTION', $content_options);
                 $content_variants .= $content_item_variant;
             }
             // Generate HTML for variants tab block
             $markerArray = array();
             $markerArray['LABEL_HEADING_TAB_VARIANTS'] = 'VARIANTS';
             $content = $reference->cObj->substituteMarkerArray($subparts['template'], $markerArray, '###|###');
             $content = $reference->cObj->substituteSubpart($content, 'ITEM_VARIANT', $content_variants);
         }
     }
     $params['plugins_extra_tab']['tabs_header'][] = '<li><a href="#product_variants">VARIANTS</a></li>';
     //$params['plugins_extra_tab']['tabs_content'][] =
     //  '<div style="display:none;" id="product_variants" class="tab_content">'.$res.'</div';
     $params['plugins_extra_tab']['tabs_content'][] = $content;
     //----------------------------------------
     // VARIANTS IMAGES TAB
     //----------------------------------------
     // product Attribute
     //if (!$reference->ms['MODULES']['DISABLE_PRODUCT_VARIANTS_TAB_IN_EDITOR']) {
     // Get HTML template file
     if ($reference->conf['edit_variants_images_tmpl_path']) {
         $template = $reference->cObj->fileResource($reference->conf['edit_variants_images_tmpl_path']);
     } else {
         $template = $reference->cObj->fileResource(t3lib_extMgm::siteRelPath('msvariants') . 'Templates/edit_variants_images.tmpl');
     }
     // Extract the subparts from the template
     $subparts = array();
     $subparts['template'] = $reference->cObj->getSubpart($template, '###TEMPLATE###');
     $subparts['item_variant_images'] = $reference->cObj->getSubpart($subparts['template'], '###ITEM_VARIANT_IMAGES###');
     $subparts['item_option'] = $reference->cObj->getSubpart($subparts['template'], '###ITEM_OPTION###');
     // Get variants from db
     $sql_pa = $GLOBALS['TYPO3_DB']->SELECTquery('vars.variant_id, vars.product_id, vars.variant_price, vars.variant_stock, vars.variant_sku, vattrs.attribute_id, vattrs.option_id, vattrs.option_value_id', 'tx_msvariants_domain_model_variants vars, tx_msvariants_domain_model_variantsattributes vattrs', "vars.product_id='" . $product['products_id'] . "' and vars.variant_id=vattrs.variant_id", '', '', '');
     $qry_pa = $GLOBALS['TYPO3_DB']->sql_query($sql_pa);
     // Generate HTML for variants tab block if there are variants
     if ($product['products_id']) {
         if ($GLOBALS['TYPO3_DB']->sql_num_rows($qry_pa) > 0) {
             $variants_data = array();
             $variants_attributes_data = array();
             while (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($qry_pa)) != false) {
                 if (!$variants_data[$row['variant_id']]) {
                     $variants_data[$row['variant_id']] = array('variant_id' => $row['variant_id'], 'product_id' => $row['product_id'], 'variant_price' => $row['variant_price'], 'variant_stock' => $row['variant_stock'], 'variant_sku' => $row['variant_sku']);
                 }
                 $row['option_name'] = mslib_fe::getRealNameOptions($row['option_id']);
                 $row['option_value_name'] = mslib_fe::getNameOptions($row['option_value_id']);
                 $variants_attributes_data[$row['variant_id']][] = $row;
             }
             // Generate HTML for variants
             $nVariant = 0;
             foreach ($variants_data as $variant) {
                 $nVariant++;
                 $variant_name = 'Variant: ';
                 // generate HTML for variant's attributes
                 $content_options = '';
                 $markerArray = array();
                 foreach ($variants_attributes_data[$variant['variant_id']] as $variant_attribute) {
                     $markerArray['OPTION_NAME'] = $variant_attribute['option_name'];
                     $markerArray['OPTION_VALUE'] = $variant_attribute['option_value_name'];
                     $content_options .= $reference->cObj->substituteMarkerArray($subparts['item_option'], $markerArray, '###|###');
                     $variant_name .= $variant_attribute['option_value_name'] . " - ";
                 }
                 // generate HTML for variant details
                 $markerArray = array();
                 $markerArray['LABEL_VARIANT_NAME'] = $variant_name;
                 $markerArray['LABEL_SKU'] = 'SKU';
                 $markerArray['VARIANT_ID'] = $variant['variant_id'];
                 $markerArray['SKU'] = $variant['variant_sku'];
                 // images tab
                 $images_tab_block = '';
                 for ($x = 0; $x < $reference->ms['MODULES']['NUMBER_OF_PRODUCT_IMAGES']; $x++) {
                     $i = $x;
                     if ($i == 0) {
                         $i = '';
                     }
                     $images_tab_block .= '
         <div class="account-field" id="msEditProductInputImage_' . $i . '">
           <label for="variants_image_' . $nVariant . '_' . $i . '">' . $reference->pi_getLL('admin_image') . ' ' . ($i + 1) . '</label>
           <div id="variants_image_' . $nVariant . '_' . $i . '">
             <noscript>
               <input name="variants_image_' . $nVariant . '_' . $i . '" type="file" />
             </noscript>
           </div>
           <input name="ajax_variants_image_' . $nVariant . '_' . $i . '" id="ajax_variants_image_' . $nVariant . '_' . $i . '" type="hidden" value="" />';
                     if ($_REQUEST['action'] == 'edit_product' and $product['variants_image_' . $nVariant . '_' . $i]) {
                         $images_tab_block .= '<img src="' . mslib_befe::getImagePath($product['variants_image_' . $nVariant . '_' . $i], 'products', '50') . '">';
                         $images_tab_block .= ' <a href="' . mslib_fe::typolink(',2002', '&tx_multishop_pi1[page_section]=admin_ajax&cid=' . $_REQUEST['cid'] . '&pid=' . $_REQUEST['pid'] . '&action=edit_product&delete_image=variants_image_' . $nVariant . '_' . $i) . '" onclick="return confirm(\'Are you sure?\')"><img src="' . $reference->FULL_HTTP_URL_MS . 'templates/images/icons/delete2.png" border="0" alt="' . $reference->pi_getLL('admin_delete_image') . '"></a>';
                     }
                     $images_tab_block .= '</div>';
                 }
                 $images_tab_block .= '<script>
         jQuery(document).ready(function($) {';
                 for ($x = 0; $x < $reference->ms['MODULES']['NUMBER_OF_PRODUCT_IMAGES']; $x++) {
                     $i = $x;
                     if ($i == 0) {
                         $i = '';
                     }
                     $images_tab_block .= '
             var products_name=$("#products_name_0").val();
             var uploader' . $i . ' = new qq.FileUploader({
               element: document.getElementById(\'variants_image_' . $nVariant . '_' . $i . '\'),
               action: \'' . mslib_fe::typolink(',2002', '&tx_multishop_pi1[page_section]=custom_page') . '\',
               params: {
                 products_name: products_name,
                 file_type: \'products_image' . $i . '\'
               },
               template: \'<div class="qq-uploader">\' +
               \'<div class="qq-upload-drop-area"><span>' . $reference->pi_getLL('admin_label_drop_files_here_to_upload') . '</span></div>\' +
               \'<div class="qq-upload-button">' . addslashes(htmlspecialchars($reference->pi_getLL('choose_image'))) . '</div>\' +
               \'<ul class="qq-upload-list"></ul>\' +
               \'</div>\',
               onComplete: function(id, fileName, responseJSON){
                 var filenameServer = responseJSON[\'filename\'];
                 $("#ajax_variants_image_' . $nVariant . '_' . $i . '").val(filenameServer);
               },
               debug: false
             });';
                 }
                 $images_tab_block .= '
           $(\'#products_name_0\').change(function() {
             var products_name=$("#products_name_0").val();';
                 for ($x = 0; $x < $reference->ms['MODULES']['NUMBER_OF_PRODUCT_IMAGES']; $x++) {
                     $i = $x;
                     if ($i == 0) {
                         $i = '';
                     }
                     $images_tab_block .= '
               uploader' . $i . '.setParams({
                products_name: products_name,
                file_type: \'products_image' . $i . '\'
              });';
                 }
                 $images_tab_block .= '
           });
         });
       </script>';
                 $markerArray['IMAGE_CODE'] = $images_tab_block;
                 $content_item_variant_images = $reference->cObj->substituteMarkerArray($subparts['item_variant_images'], $markerArray, '###|###');
                 $content_item_variant_images = $reference->cObj->substituteSubpart($content_item_variant_images, 'ITEM_OPTION', $content_options);
                 $content_variants_images .= $content_item_variant_images;
             }
             // Generate HTML for variants tab block
             $markerArray = array();
             $markerArray['LABEL_HEADING_TAB_VARIANTS_IMAGES'] = 'VARIANTS IMAGES';
             $content2 = $reference->cObj->substituteMarkerArray($subparts['template'], $markerArray, '###|###');
             $content2 = $reference->cObj->substituteSubpart($content2, 'ITEM_VARIANT_IMAGES', $content_variants_images);
         }
     }
     $params['plugins_extra_tab']['tabs_header'][] = '<li><a href="#product_variants_images">VARIANTS IMAGES</a></li>';
     //$params['plugins_extra_tab']['tabs_content'][] =
     //  '<div style="display:none;" id="product_variants" class="tab_content">'.$res.'</div';
     $params['plugins_extra_tab']['tabs_content'][] = $content2;
 }