Index: www-lp/www/includes/functions/general.php =================================================================== diff -u -r4 -r37 --- www-lp/www/includes/functions/general.php (.../general.php) (revision 4) +++ www-lp/www/includes/functions/general.php (.../general.php) (revision 37) @@ -132,6 +132,76 @@ return $product['specials_new_products_price']; } + // Return the product price + function tep_get_products_price($product_id) { + $product_price_query = tep_db_query( + "SELECT products_price + FROM " . TABLE_PRODUCTS . " + WHERE products_status = 1 + AND products_id = " . (int)$product_id + ); + + $product_price = tep_db_fetch_array($product_price_query); + + return $product_price['products_price']; + } + + // Return the product price + function tep_get_products_cost($product_id) { + $product_price_query = tep_db_query( + "SELECT products_cost + FROM " . TABLE_PRODUCTS . " + WHERE products_status = 1 + AND products_id = " . (int)$product_id + ); + + $product_price = tep_db_fetch_array($product_price_query); + + return $product_price['products_cost']; + } + + function tep_get_sales_percentage($products_price, $specials_new_products_price ){ + return number_format(100 - (((float)$specials_new_products_price / (float)$products_price) * 100)) . '%'; +} + +function tep_get_specials_indicator($products_price, $specials_new_products_price){ + if (LPOSC_SALES_ENABLED == "True"){ + return 'SOLDES: -' . tep_get_sales_percentage($products_price, $specials_new_products_price); + } + else{ + return 'PROMOTION'; + } +} + + +function tep_get_sales_percentage_vip($products_cost, $coeff_partner, $specials_new_products_price){ + if($specials_new_products_price > ((float)$products_cost * $coeff_partner)){ + return Null; + } + + $percent_vip = number_format(100 - (((float)$specials_new_products_price / ((float)$products_cost*$coeff_partner)) * 100)); + if($percent_vip > 0 && $percent_vip < 100) + return '- ' .$percent_vip . '%'; + else{ + return Null; + } +} + +function tep_get_specials_indicator_vip($products_cost, $coeff_partner, $specials_new_products_price){ + if (LPOSC_SALES_ENABLED == "True"){ + $percent_vip = tep_get_sales_percentage_vip($products_cost, $coeff_partner, $specials_new_products_price); + if($percent_vip == Null || $percent_vip == ''){ + return ''; + } + else{ + return 'SOLDES: ' . tep_get_sales_percentage_vip($products_cost, $coeff_partner, $specials_new_products_price); + } + } + else{ + return ''; + } +} + //// // Return a product's stock // TABLES: products