function xtc_get_products_price_export($products_id, $price_special, $quantity, $group_id = 0, $add_tax = 1, $currency, $calculate_currencies = true) { // load price data into array for further use! $product_price_query = xtc_db_query("SELECT products_price,\n products_discount_allowed,\n products_tax_class_id\n FROM " . TABLE_PRODUCTS . "\n WHERE\n products_id = '" . $products_id . "'"); $product_price = xtc_db_fetch_array($product_price_query); $price_data = array(); $price_data = array('PRODUCTS_PRICE' => $product_price['products_price'], 'PRODUCTS_DISCOUNT_ALLOWED' => $product_price['products_discount_allowed'], 'PRODUCT_TAX_CLASS_ID' => $product_price['products_tax_class_id']); // get tax rate for tax class $products_tax = xtc_get_tax_rate_export($price_data['PRODUCT_TAX_CLASS_ID']); // check if user is allowed to see tax rates if ($add_tax == '0') { $products_tax = ''; } // end $_SESSION['customers_status']['customers_status_show_price_tax'] =='0' // check if special price is available for product (no product discount on special prices!) if ($special_price = xtc_get_products_special_price($products_id)) { $special_price = xtc_add_tax($special_price, $products_tax); $price_data['PRODUCTS_PRICE'] = xtc_add_tax($price_data['PRODUCTS_PRICE'], $products_tax); $price_string = xtc_format_special_price_export($special_price, $price_data['PRODUCTS_PRICE'], $price_special, $calculate_currencies = true, $quantity, $products_tax, $add_tax, $currency); } else { // if ($special_price=xtc_get_products_special_price($products_id)) // Check if there is another price for customers_group (if not, take norm price and calculte discounts (NOTE: no discount on group PRICES(only OT DISCOUNT!)! $group_price_query = xtc_db_query("SELECT personal_offer\n FROM personal_offers_by_customers_status_" . $group_id . "\n WHERE products_id='" . $products_id . "'"); $group_price_data = xtc_db_fetch_array($group_price_query); // if we found a price, everything is ok if not, we will use normal price if ($group_price_data['personal_offer'] != '' and $group_price_data['personal_offer'] != '0.0000') { $price_string = $group_price_data['personal_offer']; // check if customer is allowed to get graduated prices // if ($_SESSION['customers_status']['customers_status_graduated_prices']=='1'){ // check if there are graduated prices in db // get quantity for products // modifikations for new graduated prices $qty = xtc_get_qty($products_id); if (!xtc_get_qty($products_id)) { $qty = $quantity; } $graduated_price_query = xtc_db_query("SELECT max(quantity)\n FROM personal_offers_by_customers_status_" . $group_id . "\n WHERE products_id='" . $products_id . "'\n AND quantity<='" . $qty . "'"); $graduated_price_data = xtc_db_fetch_array($graduated_price_query); // get singleprice $graduated_price_query = xtc_db_query("SELECT personal_offer\n FROM personal_offers_by_customers_status_" . $group_id . "\n WHERE products_id='" . $products_id . "'\n AND quantity='" . $graduated_price_data['max(quantity)'] . "'"); $graduated_price_data = xtc_db_fetch_array($graduated_price_query); $price_string = $graduated_price_data['personal_offer']; // } // end $_SESSION['customers_status']['customers_status_graduated_prices']=='1' $price_string = xtc_add_tax($price_string, $products_tax); //*$quantity; } else { // if ($group_price_data['personal_offer']!='' and $group_price_data['personal_offer']!='0.0000') $price_string = xtc_add_tax($price_data['PRODUCTS_PRICE'], $products_tax); //*$quantity; // check if product allows discount } // format price & calculate currency $price_string = $price_string * $quantity; // currency calculations $currencies_query = xtc_db_query("SELECT *\n FROM " . TABLE_CURRENCIES . " WHERE\n code = '" . $currency . "'"); $currencies_value = xtc_db_fetch_array($currencies_query); $currencies_data = array(); $currencies_data = array('SYMBOL_LEFT' => $currencies_value['symbol_left'], 'SYMBOL_RIGHT' => $currencies_value['symbol_right'], 'DECIMAL_PLACES' => $currencies_value['decimal_places'], 'VALUE' => $currencies_value['value']); if ($calculate_currencies == 'true') { $price_string = $price_string * $currencies_data['VALUE']; } $price_string = xtc_precision($price_string, $currencies_data['DECIMAL_PLACES']); if ($price_special == '1') { $currencies_query = xtc_db_query("SELECT *\n FROM " . TABLE_CURRENCIES . " WHERE\n code = '" . $currency . "'"); $currencies_value = xtc_db_fetch_array($currencies_query); $price_string = number_format($price_string, $currencies_data['DECIMAL_PLACES'], $currencies_value['decimal_point'], $currencies_value['thousands_point']); if ($show_currencies == 1) { $price_string = $currencies_data['SYMBOL_LEFT'] . ' ' . $price_string . ' ' . $currencies_data['SYMBOL_RIGHT']; } } } //} return $price_string; // return $price_data['PRODUCTS_PRICE']; }
/** * Searches the graduated price of a product for a specified quantity * * @param Integer $pID product id * @param Double $qty quantity * @return Double graduated price */ function xtcGetGraduatedPrice($pID, $qty) { if (defined('GRADUATED_ASSIGN') && GRADUATED_ASSIGN == 'true') { $actual_content_qty = xtc_get_qty($pID); $qty = $actual_content_qty > $qty ? $actual_content_qty : $qty; } if (empty($this->actualGroup)) { $this->actualGroup = DEFAULT_CUSTOMERS_STATUS_ID_GUEST; } $graduated_price_query = xtDBquery("SELECT max(quantity) AS qty\n FROM " . TABLE_PERSONAL_OFFERS_BY . $this->actualGroup . "\n WHERE products_id='" . $pID . "'\n AND quantity<='" . $qty . "'"); $graduated_price_data = xtc_db_fetch_array($graduated_price_query, true); if ($graduated_price_data['qty']) { $graduated_price_query = xtDBquery("SELECT personal_offer\n FROM " . TABLE_PERSONAL_OFFERS_BY . $this->actualGroup . "\n WHERE products_id='" . $pID . "'\n AND quantity='" . $graduated_price_data['qty'] . "'"); $graduated_price_data = xtc_db_fetch_array($graduated_price_query, true); $sPrice = $graduated_price_data['personal_offer']; if ($sPrice != 0.0) { return $sPrice; } } else { return; } }