Esempio n. 1
0
         }
         $products_options_list_noscript = implode($products_options_noscript_array);
         if (xos_not_null($products_options_array)) {
             $product_options_array[] = array('products_options_name' => $products_options_name['products_options_name'], 'products_options_id' => $products_options_name['products_options_id'], 'products_options_list_noscript' => $products_options_list_noscript, 'products_options_pull_down' => xos_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute, 'class="form-control" id="option_' . $products_options_name['products_options_id'] . '" onchange="updateOptions(\'' . xos_href_link(FILENAME_UPDATE_OPTIONS, 'p=' . xos_get_prid($_GET['p']), 'NONSSL', true, false) . '\')"'));
             //                                           'products_options_pull_down' => xos_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute, 'class="form-control" id="option_' . $products_options_name['products_options_id'] . '" onchange="change_action(this.form); this.form.submit();"'));
         }
     }
     $jscript_op = '<script type="text/javascript">' . "\n\n" . '    var http_request = false;' . "\n\n" . '    function updateOptions(url,serialized_attributes) {' . "\n\n" . '      var serialized_options = "";' . "\n\n" . '      if(typeof(serialized_attributes) == "undefined"){' . "\n" . '        for (var i = 0; i < document.getElementsByTagName("select").length; i++) {' . "\n" . '          if(document.getElementsByTagName("select")[i].form.name == "cart_quantity") {' . "\n" . '            option_name = document.getElementsByTagName("select")[i].name;' . "\n" . '            selected_options_value_id = document.getElementsByTagName("select")[i].options[document.getElementsByTagName("select")[i].selectedIndex].value;' . "\n" . '            serialized_options += option_name + "=" + selected_options_value_id + "&";' . "\n" . '          }' . "\n" . '        }' . "\n" . '      } else {' . "\n" . '        serialized_options = serialized_attributes;' . "\n" . '      }' . "\n\n" . '      http_request = false;' . "\n\n" . '      if (window.XMLHttpRequest) { // Mozilla, Safari,...' . "\n" . '        http_request = new XMLHttpRequest();' . "\n" . '        if (http_request.overrideMimeType) {' . "\n" . '          http_request.overrideMimeType("text/html");' . "\n" . '        }' . "\n" . '      } else if (window.ActiveXObject) { // IE' . "\n" . '        try {' . "\n" . '          http_request = new ActiveXObject("Msxml2.XMLHTTP");' . "\n" . '        } catch (e) {' . "\n" . '          try {' . "\n" . '            http_request = new ActiveXObject("Microsoft.XMLHTTP");' . "\n" . '          } catch (e) {}' . "\n" . '        }' . "\n" . '      }' . "\n\n" . '      if (!http_request) {' . "\n" . '        alert("Ende : Kann keine XMLHTTP-Instanz erzeugen");' . "\n" . '        return false;' . "\n" . '      }' . "\n" . '      http_request.onreadystatechange = response_processing;' . "\n" . '      http_request.open("POST", url, true);' . "\n" . '      http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");' . "\n" . '      http_request.send(encodeURI(serialized_options));' . "\n\n" . '    }' . "\n\n" . '    function response_processing() {' . "\n" . '      if (http_request.readyState == 1) {' . "\n" . '        document.getElementById("options").style.visibility = "hidden";' . "\n" . '        document.getElementById("loading").style.visibility = "visible";' . "\n" . '        document.getElementById("inc").style.visibility = "hidden";' . "\n" . '        document.getElementById("dec").style.visibility = "hidden";' . "\n" . '        document.getElementById("products_quantity").style.visibility = "hidden";' . "\n" . '        document.getElementById("add_to_cart").style.visibility = "hidden";' . "\n" . '      } else if (http_request.readyState == 4) {' . "\n" . '        if (http_request.status == 200) {' . "\n" . '          document.getElementById("options").innerHTML = http_request.responseText;' . "\n" . '          document.getElementById("options").style.visibility = "visible";' . "\n" . '          document.getElementById("loading").style.visibility = "hidden";' . "\n" . '          document.getElementById("inc").style.visibility = "visible";' . "\n" . '          document.getElementById("dec").style.visibility = "visible";' . "\n" . '          document.getElementById("products_quantity").style.visibility = "visible";' . "\n" . '          document.getElementById("add_to_cart").style.visibility = "visible";' . "\n" . '        } else {' . "\n" . '          alert("Bei dem Request ist ein Problem aufgetreten.");' . "\n" . '        }' . "\n" . '      }' . "\n" . '    }' . "\n\n" . '    function getOptionsList(url) {' . "\n\n" . '      if (typeof(isLoaded) != "undefined" && isLoaded == true) {' . "\n" . '          toggle("box_products_options_overview");' . "\n" . '      } else {' . "\n\n" . '        http_request = false;' . "\n\n" . '        if (window.XMLHttpRequest) { // Mozilla, Safari,...' . "\n" . '            http_request = new XMLHttpRequest();' . "\n" . '            if (http_request.overrideMimeType) {' . "\n" . '                http_request.overrideMimeType("text/html");' . "\n" . '            }' . "\n" . '        } else if (window.ActiveXObject) { // IE' . "\n" . '            try {' . "\n" . '                http_request = new ActiveXObject("Msxml2.XMLHTTP");' . "\n" . '            } catch (e) {' . "\n" . '                try {' . "\n" . '                    http_request = new ActiveXObject("Microsoft.XMLHTTP");' . "\n" . '                } catch (e) {}' . "\n" . '            }' . "\n" . '        }' . "\n\n" . '        if (!http_request) {' . "\n" . '            alert("Ende : Kann keine XMLHTTP-Instanz erzeugen");' . "\n" . '            return false;' . "\n" . '        }' . "\n" . '        http_request.onreadystatechange = response_processing_list;' . "\n" . '        http_request.open("GET", url, true);' . "\n" . '        http_request.send(null);' . "\n\n" . '      }' . "\n\n" . '    }' . "\n\n" . '    function response_processing_list() {' . "\n" . '      if (http_request.readyState == 1) {' . "\n" . '        $("#loading_list").show(1);' . "\n" . '      } else if (http_request.readyState == 4) {' . "\n" . '        if (http_request.status == 200) {' . "\n" . '          document.getElementById("box_products_options_overview").innerHTML = http_request.responseText;' . "\n" . '          document.getElementById("loading_list").style.display = "none";' . "\n" . '          isLoaded = true;' . "\n" . '          toggle("box_products_options_overview");' . "\n" . '        } else {' . "\n" . '          alert("Bei dem Request ist ein Problem aufgetreten.");' . "\n" . '        }' . "\n" . '      }' . "\n" . '    }' . "\n\n" . '    function getAbsoluteX (elm) {' . "\n" . '      var x = 0;' . "\n" . '      if (elm && typeof elm.offsetParent != "undefined") {' . "\n" . '        while (elm && typeof elm.offsetLeft == "number") {' . "\n" . '          x += elm.offsetLeft;' . "\n" . '          elm = elm.offsetParent;' . "\n" . '        }' . "\n" . '      }' . "\n" . '      return x;' . "\n" . '    }' . "\n\n" . '    function toggle(targetId) {' . "\n" . '      var elem = document.getElementById(targetId);' . "\n" . '      if (elem.style.display == "none"){' . "\n" . '        elem.style.display="block";' . "\n" . '        var x = getAbsoluteX(elem);' . "\n" . '        elem.style.display="none";' . "\n" . '        if (x < 0){' . "\n" . '          oldRightValue = elem.style.right;' . "\n" . '          $("#"+targetId).css({"right" : x+"px"}).show(1);' . "\n" . '        } else {' . "\n" . '          $("#"+targetId).show(1);' . "\n" . '        }' . "\n" . '      } else {' . "\n" . '        if(typeof(oldRightValue) != "undefined" && oldRightValue != ""){' . "\n" . '          elem.style.right=oldRightValue;' . "\n" . '        }' . "\n" . '        elem.style.display="none";' . "\n" . '      }' . "\n" . '    }' . "\n\n" . '    function toggleByClassName(targetClass) {' . "\n" . '      var allElems = document.getElementsByTagName("span");' . "\n" . '      for (var i = 0; i < allElems.length; i++) {' . "\n" . '        var thisElem = allElems[i];' . "\n" . '        if (thisElem.className && thisElem.className == targetClass) {' . "\n" . '          if (thisElem.style.display == "none"){' . "\n" . '            thisElem.style.display = "";' . "\n" . '          } else {' . "\n" . '            thisElem.style.display = "none";' . "\n" . '          }' . "\n" . '        }' . "\n" . '      }' . "\n" . '    }' . "\n\n" . '</script>' . "\n";
     if (xos_not_null($attributes_quantity) && STOCK_CHECK == 'true') {
         if ($flag == false) {
             $combi_str .= $c_str;
         }
         $att_qty = $attributes_quantity[substr($combi_str, 0, -1)];
         $smarty->assign('qty_for_these_options', $att_qty > 0 ? $att_qty : '<span class="red-mark">' . $att_qty . '</span>');
     }
     $smarty->assign(array('link_options_noscript' => xos_href_link(FILENAME_OPTIONS_WINDOW, 'p=' . $product_info['products_id'] . '&products_name=' . urlencode($product_info['products_name'])), 'get_otions_list' => 'getOptionsList(\'' . xos_href_link(FILENAME_OPTIONS_LIST, 'p=' . xos_get_prid($_GET['p']), 'NONSSL', true, false) . '\');', 'products_options' => $product_options_array));
 }
 $reviews_query = xos_db_query("select count(*) as count from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd where r.products_id = '" . (int) $_GET['p'] . "' and r.reviews_id = rd.reviews_id and rd.languages_id = '" . (int) $_SESSION['languages_id'] . "'");
 $reviews = xos_db_fetch_array($reviews_query);
 if ($reviews['count'] > 0) {
     $smarty->assign('reviews_count', $reviews['count']);
 }
 if (xos_not_null($product_info['products_url'])) {
     $smarty->assign('link_products_url', xos_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($product_info['products_url']), 'NONSSL', true, false));
 }
 if ($product_info['products_date_available'] > 0) {
     $smarty->assign('products_date_available', xos_date_long($product_info['products_date_available']));
 } else {
     $smarty->assign('products_date_added', xos_date_long($product_info['products_date_added']));
 }
 if (PRODUCT_REVIEWS_ENABLED == 'true') {
                 $smarty->clearCache(null, 'L3|cc_product_info');
             }
             if ($stock_values['products_quantity'] < 1 && STOCK_ALLOW_CHECKOUT == 'false') {
                 xos_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . (int) $product_id . "'");
                 $smarty->clearAllCache();
             }
         }
     }
 }
 // Update products_ordered (for bestsellers list)
 xos_db_query("update " . TABLE_PRODUCTS . " set products_last_modified = now(), products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . xos_get_prid($order->products[$i]['id']) . "'");
 $attributes_sting = null;
 if (strpos($order->products[$i]['id'], '-') !== false) {
     list($prid, $attributes_sting) = explode('-', $order->products[$i]['id']);
 }
 $sql_data_array = array('orders_id' => $insert_id, 'products_id' => xos_get_prid($order->products[$i]['id']), 'products_attributes_sting' => $attributes_sting, 'products_model' => $order->products[$i]['model'], 'products_name' => $order->products[$i]['name'], 'products_p_unit' => $order->products[$i]['packaging_unit'], 'products_price' => $order->products[$i]['price'], 'final_price' => $order->products[$i]['final_price'], 'products_price_text' => $order->products[$i]['price_formated'], 'final_price_text' => $order->products[$i]['final_price_formated'], 'total_price_text' => $order->products[$i]['total_price_formated'], 'products_tax' => $order->products[$i]['tax'], 'products_quantity' => $order->products[$i]['qty']);
 xos_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);
 $order_products_id = xos_db_insert_id();
 //------insert customer choosen option to order--------
 $attributes_exist = '0';
 $attributes_options_values_price = false;
 if (isset($order->products[$i]['attributes'])) {
     $attributes_exist = '1';
     $order_attributes_array = array();
     for ($j = 0, $n2 = sizeof($order->products[$i]['attributes']); $j < $n2; $j++) {
         if (DOWNLOAD_ENABLED == 'true') {
             $attributes_query = "select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix, pad.products_attributes_maxdays, pad.products_attributes_maxcount , pad.products_attributes_filename \n                               from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa \n                               left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad\n                                on pa.products_attributes_id=pad.products_attributes_id\n                               where pa.products_id = '" . $order->products[$i]['id'] . "' \n                                and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' \n                                and pa.options_id = popt.products_options_id \n                                and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' \n                                and pa.options_values_id = poval.products_options_values_id \n                                and popt.language_id = '" . $_SESSION['languages_id'] . "' \n                                and poval.language_id = '" . $_SESSION['languages_id'] . "'";
             $attributes = xos_db_query($attributes_query);
         } else {
             $attributes = xos_db_query("select popt.products_options_name, poval.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa where pa.products_id = '" . $order->products[$i]['id'] . "' and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $_SESSION['languages_id'] . "' and poval.language_id = '" . $_SESSION['languages_id'] . "'");
         }
Esempio n. 3
0
     $comb_string = '';
     $serialized_options = '';
     for ($ii = 0, $m = sizeof($opt_values_array); $ii < $m; $ii++) {
         if ($i < $opt_array[$ii]['rows_per_value'] * max(1, $opt_rows_array[$ii] + 1)) {
         } else {
             $opt_rows_array[$ii] = $opt_rows_array[$ii] + 1;
             $opt_out_array[$ii] = $opt_out_array[$ii] + 1;
             if ($opt_out_array[$ii] % $opt_array[$ii]['options_values_qty'] == 0) {
                 $opt_out_array[$ii] = 0;
             }
         }
         $opt_result_array[$i][$ii] = $opt_values_array[$opt_array[$ii]['options_id']][max(0, $opt_out_array[$ii])]['options_values_name'];
         $comb_string .= $opt_array[$ii]['options_id'] . ',' . $opt_values_array[$opt_array[$ii]['options_id']][max(0, $opt_out_array[$ii])]['options_values_id'] . '_';
         $serialized_options .= 'id[' . $opt_array[$ii]['options_id'] . ']=' . $opt_values_array[$opt_array[$ii]['options_id']][max(0, $opt_out_array[$ii])]['options_values_id'] . '&';
     }
     $onclick_update_options_string = '<a class="options-list" href="" onclick="updateOptions(\'' . xos_href_link(FILENAME_UPDATE_OPTIONS, 'p=' . xos_get_prid($_GET['p']), 'NONSSL', true, false) . '\',\'' . $serialized_options . '\'); toggle(\'box_products_options_overview\'); return false">' . xos_image(DIR_WS_IMAGES . 'catalog/templates/' . SELECTED_TPL . '/' . 'pixel_trans.gif', TEXT_OPTION_TO_INSERT, '16', '16') . '</a>';
     $comb_string = substr($comb_string, 0, -1);
     if (isset($attributes_quantity[$comb_string])) {
         $opt_result_array[$i][sizeof($opt_values_array)] = STOCK_CHECK == 'true' ? isset($attributes_quantity[$comb_string]) ? $attributes_quantity[$comb_string] <= 0 ? STOCK_ALLOW_CHECKOUT == 'false' ? '<span class="red-mark options-list">0</span>' : '<span class="red-mark options-list">' . $attributes_quantity[$comb_string] . '</span>' : '<span class="options-list">' . $attributes_quantity[$comb_string] . '</span>' : '' : 'tick';
         $opt_result_array[$i][sizeof($opt_values_array) + 1] = STOCK_CHECK == 'true' ? isset($attributes_quantity[$comb_string]) ? $attributes_quantity[$comb_string] <= 0 ? STOCK_ALLOW_CHECKOUT == 'false' ? '<span class="options-list-draw-separator">' . xos_image(DIR_WS_IMAGES . 'catalog/templates/' . SELECTED_TPL . '/' . 'pixel_trans.gif', '', '16', '16') . '</span>' : $onclick_update_options_string : $onclick_update_options_string : '<span class="options-list-draw-separator">' . xos_image(DIR_WS_IMAGES . 'catalog/templates/' . SELECTED_TPL . '/' . 'pixel_trans.gif', '', '16', '16') . '</span>' : $onclick_update_options_string;
     } else {
         $opt_result_array[$i][sizeof($opt_values_array)] = STOCK_CHECK == 'true' ? '<span class="red-mark options-list">X</span>' : 'cross';
         $opt_result_array[$i][sizeof($opt_values_array) + 1] = '<span class="options-list-draw-separator">' . xos_image(DIR_WS_IMAGES . 'catalog/templates/' . SELECTED_TPL . '/' . 'pixel_trans.gif', '', '16', '16') . '</span>';
         //      unset($opt_result_array[$i]);
     }
 }
 unset($opt_array['rows_total']);
 $combinations_array = array();
 $combinations_array['options_names'] = $opt_array;
 $combinations_array['options_values'] = $opt_result_array;
 $smarty->assign(array('products_options_overview' => $combinations_array, 'options_values_price' => $options_values_price, 'stock_allow_checkout' => STOCK_ALLOW_CHECKOUT, 'stock_check' => STOCK_CHECK));
Esempio n. 4
0
                    $products_options_array[] = array('id' => $products_options['products_options_values_id'], 'text' => $products_options['products_options_values_name']);
                    if ($products_options['options_values_price'] != '0') {
                        $products_options_array[sizeof($products_options_array) - 1]['text'] .= ' (' . $products_options['price_prefix'] . $currencies->display_price($products_options['options_values_price'], $products_tax_rate) . ') ';
                    }
                    if ($flag == false) {
                        if ($selected_attribute == false) {
                            $combi_str .= $products_options_name['products_options_id'] . ',' . $products_options['products_options_values_id'] . '_';
                            $flag = true;
                        } elseif ($selected_attribute == $products_options['products_options_values_id']) {
                            $combi_str .= $products_options_name['products_options_id'] . ',' . $products_options['products_options_values_id'] . '_';
                            $flag = true;
                        }
                    }
                }
            }
            if (xos_not_null($products_options_array)) {
                $product_options_array[] = array('products_options_name' => $products_options_name['products_options_name'], 'products_options_id' => $products_options_name['products_options_id'], 'products_options_pull_down' => xos_draw_pull_down_menu('id[' . $products_options_name['products_options_id'] . ']', $products_options_array, $selected_attribute, 'class="form-control" id="option_' . $products_options_name['products_options_id'] . '" onchange="updateOptions(\'' . xos_href_link(FILENAME_UPDATE_OPTIONS, 'p=' . xos_get_prid($_GET['p']), 'NONSSL', true, false) . '\')"'));
            }
        }
        if (xos_not_null($attributes_quantity) && STOCK_CHECK == 'true') {
            if ($flag == false) {
                $combi_str .= $c_str;
            }
            $att_qty = $attributes_quantity[substr($combi_str, 0, -1)];
            $smarty->assign('qty_for_these_options', $att_qty > 0 ? $att_qty : '<span class="red-mark">' . $att_qty . '</span>');
        }
        $smarty->assign(array('get_otions_list' => 'getOptionsList(\'' . xos_href_link(FILENAME_OPTIONS_LIST, 'p=' . xos_get_prid($_GET['p']), 'NONSSL', true, false) . '\');', 'products_options' => $product_options_array));
    }
    $smarty->configLoad('languages/' . $_SESSION['language'] . '.conf', 'product_info');
    $smarty->display(SELECTED_TPL . '/update_options.tpl');
}
Esempio n. 5
0
function xos_get_uprid($prid, $params)
{
    if (is_numeric($prid)) {
        $uprid = $prid;
        if (is_array($params) && sizeof($params) > 0) {
            $attributes_check = true;
            $attributes_ids = '';
            reset($params);
            while (list($option, $value) = each($params)) {
                if (is_numeric($option) && is_numeric($value)) {
                    $attributes_ids .= (int) $option . ',' . (int) $value . '_';
                } else {
                    $attributes_check = false;
                    break;
                }
            }
            $attributes_ids = substr($attributes_ids, 0, -1);
            if ($attributes_check == true) {
                $uprid .= ($attributes_ids != '' ? '-' : '') . $attributes_ids;
            }
        }
    } else {
        $uprid = xos_get_prid($prid);
        if (is_numeric($uprid)) {
            if (strpos($prid, '-') !== false) {
                $attributes_check = true;
                $attributes_ids = '';
                list($prid, $params_sting) = explode('-', $prid);
                $params = explode('_', $params_sting);
                for ($i = 0, $n = sizeof($params); $i < $n; $i++) {
                    $pair = explode(',', $params[$i]);
                    if (is_numeric($pair[0]) && is_numeric($pair[1])) {
                        $attributes_ids .= (int) $pair[0] . ',' . (int) $pair[1] . '_';
                    } else {
                        $attributes_check = false;
                        break;
                    }
                }
                $attributes_ids = substr($attributes_ids, 0, -1);
                if ($attributes_check == true) {
                    $uprid .= ($attributes_ids != '' ? '-' : '') . $attributes_ids;
                }
            }
        } else {
            return false;
        }
    }
    return $uprid;
}
Esempio n. 6
0
 function get_products()
 {
     if (!is_array($this->contents)) {
         return 0;
     }
     $products_array = array();
     reset($this->contents);
     while (list($products_id, ) = each($this->contents)) {
         $products_query = xos_db_query("select p.products_id, pd.products_name, p.products_model, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id='" . (int) xos_get_prid($products_id) . "' and pd.products_id = p.products_id and pd.language_id = '" . (int) $_SESSION['costom_lang_id'] . "'");
         if ($products = xos_db_fetch_array($products_query)) {
             $products_array[] = array('id' => $products_id, 'name' => $products['products_name'], 'quantity' => $this->contents[$products_id]['qty']);
         }
     }
     return $products_array;
 }
Esempio n. 7
0
 function update_quantity($products_id, $quantity = '', $attributes = '')
 {
     $products_id_string = xos_get_uprid($products_id, $attributes);
     $products_id = xos_get_prid($products_id_string);
     if (is_numeric($products_id) && isset($this->contents[$products_id_string]) && is_numeric($quantity)) {
         $this->contents[$products_id_string] = array('qty' => $quantity);
         // update database
         if (isset($_SESSION['customer_id'])) {
             xos_db_query("update " . TABLE_CUSTOMERS_BASKET . " set customers_basket_quantity = '" . (int) $quantity . "' where customers_id = '" . (int) $_SESSION['customer_id'] . "' and products_id = '" . xos_db_input($products_id_string) . "'");
         }
         if (is_array($attributes)) {
             reset($attributes);
             while (list($option, $value) = each($attributes)) {
                 $this->contents[$products_id_string]['attributes'][$option] = $value;
             }
         }
     }
 }