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"); }
for ($x = 0; $x < $count_manual_attributes; $x++) { if (strpos($this->post['edit_manual_price'][$x], '-') !== false) { $price_prefix = '-'; $this->post['edit_manual_price'][$x] = str_replace('-', '', $this->post['edit_manual_price'][$x]); } 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);
$return_data['delete_id'] = '#options_' . $option_id; } $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'];
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; }