View Single Post
  #5  
Old 03-02-2005, 05:45 AM
 
Dybbuk Dybbuk is offline
 

Advanced Member
  
Join Date: Feb 2005
Posts: 77
 

Default Re: Speed up Smarty templates by taking out {math} functions

Quote:
Originally Posted by NuAlpha
Find the function func_select_product in func.php and add this to the $product = func_query_first( SQL statement to replace the 'savings' and 'discount' math calculations:
Code:
100-($sql_tbl[pricing].price/$sql_tbl[products].list_price)*100 AS discount, $sql_tbl[products].list_price-$sql_tbl[pricing].price AS savings,
Below the select statement, add the following to replace the 'mq' math calculation:
Code:
if ($product) { if ($config['General']['unlimited_products'] == 'Y') $product['min_quantity'] = $config['Appearance']['max_select_quantity']+1; else { $tmp_compare = $config['Appearance']['max_select_quantity']/$product['min_amount']; if ($tmp_compare < 2) $minamount = $product['min_amount']; else $minamount = 0; $product['min_quantity'] = min($config['Appearance']['max_select_quantity']+$minamount, $product['avail'])+1; } }

Does this work for 4.0.11? Bit confused. In my func.php I have the following:

Code:
$product = func_query_first("SELECT $sql_tbl[products].*, $sql_tbl[products].avail-$in_cart AS avail, min($sql_tbl[pricing].price) AS price $add_fields FROM $sql_tbl[products], $sql_tbl[pricing] $join WHERE $sql_tbl[products].productid='$id' ".$login_condition." AND $sql_tbl[pricing].productid=$sql_tbl[products].productid AND $sql_tbl[pricing].quantity=1 AND $sql_tbl[pricing].variantid = 0 AND ($sql_tbl[pricing].membership = '$membership' OR $sql_tbl[pricing].membership = '') GROUP BY $sql_tbl[products].productid");

I'm not exactly sure where to add NuAlpha's code (ie., after the SELECT statement, before, in the middle, as a replacement...)

Could somebody post an example of what the finished snippet of code in func.php should look like? Not being cheeky, I'm just uncertain how to proceed with this correctly.

Cheers,

DB
__________________
Version 4.0.16
Reply With Quote