I am trying to port an OSC PDF Catalog Creator to Zencart and am replacing OSC PHP code with Zencart PHP Code. I am a bit stuck with the following and would be grateful if someone could glance over it for me:
ORIGINAL OSC CODE
PHP Code:
if(VAT == '1')
{
$vatprice_query=tep_db_query("select p.products_id, p.products_tax_class_id, tr.tax_rate from " . TABLE_PRODUCTS . " p, " . TABLE_TAX_RATES . " tr where p.products_id = '" . $data_array[10] . "' and p.products_tax_class_id = tr.tax_class_id");
while($vatprice1 = tep_db_fetch_array($vatprice_query)) {
$steuer = $vatprice1['tax_rate'];
}
$vatprice=sprintf("%01.".DIGITS_AFTER_DOT."f",(($steuer/100)*$data_array[9])+$data_array[9]);
$vatspecialsprice=sprintf("%01.".DIGITS_AFTER_DOT."f",(($steuer/100)*$data_array[8])+$data_array[8]);
}
else
{
$vatprice=sprintf("%01.".DIGITS_AFTER_DOT."f",$data_array[9]);
$vatspecialsprice=sprintf("%01.".DIGITS_AFTER_DOT."f",$data_array[8]);
}
MY PHP CODE ATTEMPT FOR ZENCART
PHP Code:
global $db;
if(VAT == '1')
{
$query= "SELECT p.products_id, p.products_tax_class_id, tr.tax_rate from (" . TABLE_PRODUCTS . " p, " . TABLE_TAX_RATES . " tr) where p.products_id = '" . $data_array[10] . "' and p.products_tax_class_id = tr.tax_class_id";
$vatprice = $db->Execute($query);
while (!$vatprice->EOF) {
$steuer = $vatprice['tax_rate'];
}
$vatprice=sprintf("%01.".DIGITS_AFTER_DOT."f",(($steuer/100)*$data_array[9])+$data_array[9]);
$vatspecialsprice=sprintf("%01.".DIGITS_AFTER_DOT."f",(($steuer/100)*$data_array[8])+$data_array[8]);
}
else
{
$vatprice=sprintf("%01.".DIGITS_AFTER_DOT."f",$data_array[9]);
$vatspecialsprice=sprintf("%01.".DIGITS_AFTER_DOT."f",$data_array[8]);
}
As you may have guessed I am not a PHP coder so am just following the instructions on how to port an OSC mod to Zencart. Can any PHP guru please tell me if the code I have produced is correct.
Thanks
Bookmarks