Example #1
0
function tep_get_products_special_price($x)
{
    if (function_exists('olc_get_products_special_price')) {
        return olc_get_products_special_price($x);
    }
    return FALSE;
}
function olc_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 = olc_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 . APOS);
    $product_price = olc_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 = olc_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 aviable for product (no product discount on special prices!)
    if ($special_price = olc_get_products_special_price($products_id)) {
        $special_price = olc_add_tax($special_price, $products_tax);
        $price_data['PRODUCTS_PRICE'] = olc_add_tax($price_data['PRODUCTS_PRICE'], $products_tax);
        $price_string = olc_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=olc_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 = olc_db_query("SELECT personal_offer\n                                             FROM " . TABLE_PERSONAL_OFFERS_BY_CUSTOMERS_STATUS . $group_id . "\n                                             WHERE products_id='" . $products_id . APOS);
        $group_price_data = olc_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 = olc_get_qty($products_id);
            if (!olc_get_qty($products_id)) {
                $qty = $quantity;
            }
            $graduated_price_query = olc_db_query("SELECT max(quantity)\n                                                          FROM " . TABLE_PERSONAL_OFFERS_BY_CUSTOMERS_STATUS . $group_id . "\n                                                          WHERE products_id='" . $products_id . "'\n                                                          AND quantity<='" . $qty . APOS);
            $graduated_price_data = olc_db_fetch_array($graduated_price_query);
            // get singleprice
            $graduated_price_query = olc_db_query("SELECT personal_offer\n                                                          FROM " . TABLE_PERSONAL_OFFERS_BY_CUSTOMERS_STATUS . $group_id . "\n                                                          WHERE products_id='" . $products_id . "'\n                                                          AND quantity='" . $graduated_price_data['max(quantity)'] . APOS);
            $graduated_price_data = olc_db_fetch_array($graduated_price_query);
            $price_string = $graduated_price_data['personal_offer'];
            //     } // end $_SESSION['customers_status']['customers_status_graduated_prices']=='1'
            $price_string = olc_add_tax($price_string, $products_tax);
            //*$quantity;
        } else {
            // if     ($group_price_data['personal_offer']!='' and $group_price_data['personal_offer']!='0.0000')
            $price_string = olc_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 = olc_db_query("SELECT *\n          FROM " . TABLE_CURRENCIES . " WHERE\n          code = '" . $currency . APOS);
        $currencies_value = olc_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_STRING_S) {
            $price_string = $price_string * $currencies_data['VALUE'];
        }
        $price_string = olc_precision($price_string, $currencies_data['DECIMAL_PLACES']);
        if ($price_special == '1') {
            $currencies_query = olc_db_query("SELECT *\n                                            FROM " . TABLE_CURRENCIES . " WHERE\n                                            code = '" . $currency . APOS);
            $currencies_value = olc_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'] . BLANK . $price_string . BLANK . $currencies_data['SYMBOL_RIGHT'];
            }
        }
    }
    //}
    return $price_string;
    //    return $price_data['PRODUCTS_PRICE'];
}
Example #3
0
function olc_oe_products_price($products_id, $price_special, $quantity, $customer_status)
{
    $customers_status_query = olc_db_query("select * from " . TABLE_CUSTOMERS_STATUS . " where customers_status_id = '" . $customer_status . "' ");
    $customers_status = olc_db_fetch_array($customers_status_query);
    // check if customer is allowed to see prices (if not -> no price calculations , show error message)
    if ($customers_status[customers_status_show_price] == '1') {
        // load price data into array for further use!
        $product_price_query = olc_db_query("SELECT   products_price,\n\t\t\t\t\t\t\t\t\t\t\tproducts_discount_allowed,\n\t\t\t\t\t\t\t\t\t\t\tproducts_tax_class_id\n\t\t\t\t\t\t\t\t\t\t\tFROM " . TABLE_PRODUCTS . " \n\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\tproducts_id = '" . $products_id . APOS);
        $product_price = olc_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 = olc_get_tax_rate($price_data['PRODUCT_TAX_CLASS_ID']);
        // check if user is allowed to see tax rates
        if ($customers_status['customers_status_show_price_tax'] == '0') {
            $products_tax = '';
        }
        // end $customers_status['customers_status_show_price_tax'] =='0'
        // check if special price is aviable for product (no product discount on special prices!)
        if ($special_price = olc_get_products_special_price($products_id)) {
            $special_price = olc_add_tax($special_price, $products_tax);
            $price_data['PRODUCTS_PRICE'] = olc_add_tax($price_data['PRODUCTS_PRICE'], $products_tax);
            $price_string = olc_format_special_price($special_price, $price_data['PRODUCTS_PRICE'], $price_special, $calculate_currencies = true, $quantity, $products_tax);
        } else {
            // if ($special_price=olc_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 = olc_db_query("SELECT personal_offer\n\t\t\t\t\t\t\t\t\t         FROM " . TABLE_PERSONAL_OFFERS_BY_CUSTOMERS_STATUS . $customers_status['customers_status_id'] . "\n\t\t\t\t\t\t\t\t\t         WHERE products_id='" . $products_id . APOS);
            $group_price_data = olc_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 ($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 = olc_get_qty($products_id);
                    if (!olc_get_qty($products_id)) {
                        $qty = $quantity;
                    }
                    $graduated_price_query = olc_db_query("SELECT max(quantity)\n\t\t\t\t\t\t\t\t\t                      FROM " . TABLE_PERSONAL_OFFERS_BY_CUSTOMERS_STATUS . $customers_status['customers_status_id'] . "\n\t\t\t\t\t\t\t\t\t                      WHERE products_id='" . $products_id . "'\n\t\t\t\t\t\t\t\t\t                      AND quantity<='" . $qty . APOS);
                    $graduated_price_data = olc_db_fetch_array($graduated_price_query);
                    // get singleprice
                    $graduated_price_query = olc_db_query("SELECT personal_offer\n\t\t\t\t\t                              FROM " . TABLE_PERSONAL_OFFERS_BY_CUSTOMERS_STATUS . $customers_status['customers_status_id'] . "\n\t\t\t\t\t\t\t\t\t                      WHERE products_id='" . $products_id . "'\n\t\t\t\t\t\t\t\t\t                      AND quantity='" . $graduated_price_data['max(quantity)'] . APOS);
                    $graduated_price_data = olc_db_fetch_array($graduated_price_query);
                    $price_string = $graduated_price_data['personal_offer'];
                }
                // end $_SESSION['customers_status']['customers_status_graduated_prices']=='1'
                $price_string = olc_add_tax($price_string, $products_tax);
                //*$quantity;
            } else {
                // if 	($group_price_data['personal_offer']!='' and $group_price_data['personal_offer']!='0.0000')
                $price_string = olc_add_tax($price_data['PRODUCTS_PRICE'], $products_tax);
                //*$quantity;
                // check if product allows discount
                if ($price_data['PRODUCTS_DISCOUNT_ALLOWED'] != '0.00') {
                    $discount = $price_data['PRODUCTS_DISCOUNT_ALLOWED'];
                    // check if group discount > max. discount on product
                    if ($discount > $customers_status['customers_status_discount']) {
                        $discount = $customers_status['customers_status_discount'];
                    }
                    // calculate price with rabatt
                    $rabatt_string = $price_string - $price_string / 100 * $discount;
                    if ($price_string == $rabatt_string) {
                        $price_string = olc_format_price($price_string * $quantity, $price_special, $calculate_currencies = true);
                    } else {
                        $price_string = olc_format_special_price($rabatt_string, $price_string, $price_special, $calculate_currencies = false, $quantity, $products_tax);
                    }
                    return $price_string;
                    break;
                }
            }
            // format price & calculate currency
            if ($price_string == '0.00') {
                $price_string = TEXT_NO_PRICE;
            } else {
                $price_string = olc_format_price($price_string * $quantity, $price_special, $calculate_currencies = true);
            }
        }
    } else {
        // return message, if not allowed to see prices
        $price_string = NOT_ALLOWED_TO_SEE_PRICES;
    }
    // end ($customers_status['customers_status_show_price'] == '1')
    return $price_string;
}
Example #4
0
function olc_get_products_price($products_id, $price_special, $quantity, &$price_real)
{
    global $price_data;
    // check if customer is allowed to see prices (if not -> no price calculations , show error message)
    if (CUSTOMER_SHOW_PRICE) {
        // load price data into array for further use!
        $product_price_query = olc_db_query(SELECT . "\n\t  products_price,\n\t\tproducts_discount_allowed,\n\t\tproducts_tax_class_id\n\t\tFROM " . TABLE_PRODUCTS . "\n\t\tWHERE\n\t\tproducts_id = '" . $products_id . APOS);
        $product_price = olc_db_fetch_array($product_price_query);
        $price_real = $product_price['products_price'];
        $price_data = array('PRODUCTS_PRICE' => $price_real, 'PRODUCTS_UVP' => $price_uvp, 'PRODUCTS_DISCOUNT_ALLOWED' => $product_price['products_discount_allowed'], 'PRODUCT_TAX_CLASS_ID' => $product_price['products_tax_class_id']);
        // check if user is allowed to see tax rates
        if (CUSTOMER_SHOW_PRICE_TAX) {
            // get tax rate for tax class
            $products_tax = olc_get_tax_rate($price_data['PRODUCT_TAX_CLASS_ID']);
        } else {
            $products_tax = 0;
        }
        // end !CUSTOMER_SHOW_PRICE_TAX
        $price_data['PRODUCTS_TAX_VALUE'] = $products_tax . ' %';
        // check if special price is aviable for product (no product discount on special prices!)
        //W. Kaiser - AJAX
        $special_price = olc_get_products_special_price($products_id);
        if ($special_price) {
            //W. Kaiser - AJAX
            $special_price = olc_add_tax($special_price, $products_tax);
            $price = olc_add_tax($price_data['PRODUCTS_PRICE'], $products_tax);
            $price_data['PRODUCTS_PRICE'] = $price;
            $price_string = olc_format_special_price($special_price, $price, $price_special, true, $quantity, $products_tax);
        } else {
            // if ($special_price=olc_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!)!
            $table_personal_offers = TABLE_PERSONAL_OFFERS_BY_CUSTOMERS_STATUS . CUSTOMER_STATUS_ID;
            $group_price_query = olc_db_query(SELECT . "\n\t\t\tpersonal_offer\n      FROM " . $table_personal_offers . "\n      WHERE products_id='" . $products_id . APOS);
            $group_price_data = olc_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 (CUSTOMER_SHOW_GRADUATED_PRICE) {
                    // check if there are graduated prices in db
                    // get quantity for products
                    // modifikations for new graduated prices
                    $qty = olc_get_qty($products_id);
                    if (!olc_get_qty($products_id)) {
                        $qty = $quantity;
                    }
                    $graduated_price_query = olc_db_query(SELECT . "\n\t\t\t\t\t\t\t\tmax(quantity)\n                FROM " . $table_personal_offers . "\n                WHERE products_id='" . $products_id . "'\n                AND quantity<='" . $qty . APOS);
                    $graduated_price_data = olc_db_fetch_array($graduated_price_query);
                    // get singleprice
                    $graduated_price_query = olc_db_query(SELECT . "\n\t\t\t\t\t\tpersonal_offer\n\t          FROM " . $table_personal_offers . "\n            WHERE products_id='" . $products_id . "'\n            AND quantity='" . $graduated_price_data['max(quantity)'] . APOS);
                    $graduated_price_data = olc_db_fetch_array($graduated_price_query);
                    $price_string = $graduated_price_data['personal_offer'];
                }
                $price_string = olc_add_tax($price_string, $products_tax);
                //*$quantity;
            } else {
                // if 	($group_price_data['personal_offer']!=EMPTY_STRING and $group_price_data['personal_offer']!='0.0000')
                $price_string = olc_add_tax($price_data['PRODUCTS_PRICE'], $products_tax);
                //*$quantity;
                // check if product allows discount
                if ($price_data['PRODUCTS_DISCOUNT_ALLOWED'] != '0.00') {
                    $discount = $price_data['PRODUCTS_DISCOUNT_ALLOWED'];
                    // check if group discount > max. discount on product
                    if ($discount > CUSTOMER_DISCOUNT) {
                        $discount = CUSTOMER_DISCOUNT;
                    }
                    // calculate price with rabatt
                    $rabatt_string = $price_string - $price_string / 100 * $discount;
                    if ($price_string == $rabatt_string) {
                        $price_string = olc_format_price($price_string * $quantity, $price_special, true);
                    } else {
                        $price_string = olc_format_special_price($rabatt_string, $price_string, $price_special, false, $quantity, $products_tax);
                    }
                    return $price_string;
                    break;
                }
            }
            // format price & calculate currency
            $price_string = olc_format_price($price_string * $quantity, $price_special, $calculate_currencies = true);
        }
    } else {
        // return message, if not allowed to see prices
        $price_string = NOT_ALLOWED_TO_SEE_PRICES;
    }
    return $price_string;
}
     $stored_description = true;
 } else {
     $products_values[$description_text] = $products_values[$products_description_text];
 }
 $products_min_order_quantity = $products_values['products_min_order_quantity'];
 //$quantity=max(1,$products_min_order_quantity);
 $quantity = 1;
 $products_values[$quantity_text] = $quantity;
 $pic_file_name = $products_values[$pic_url_text];
 $gallery_pic_file_name = $pic_file_name;
 $pic_url = $images_dir . $pic_file_name;
 $gallery_pic_url = $pic_url;
 $products_values[$gallery_pic_url_text] = $pic_url;
 $products_values[$pic_url_text] = $pic_url;
 $startprice = abs($products_values[$binprice_text]);
 $special_price = abs(olc_get_products_special_price($product_id));
 if ($special_price) {
     $startprice = min($startprice, abs($special_price));
 }
 $products_tax_rate = olc_get_tax_rate($products_values['products_tax_class_id']);
 if ((int) $products_tax_rate > 0) {
     $t = 100 + $products_tax_rate;
     $startprice = $startprice * $t / 100;
 }
 $t = max($quantity, $products_min_order_quantity);
 $startprice = $startprice * $t;
 $products_values[$binprice_text] = round($startprice, CURRENCY_DECIMAL_PLACES);
 $olPrice = round($startprice * 0.5, CURRENCY_DECIMAL_PLACES);
 $products_values[$startprice_text] = $olPrice;
 $products_values[$country_text] = $country;
 include_once DIR_FS_INC . 'olc_get_vpe_and_baseprice_info.inc.php';