steve_s, on Mar 20 2009, 09:16 PM, said:
Thanks Jim,
I shall do some hunting was hoping there might be a simple way to get rid of error, rest assured when i've found out i shall post solution here for others
Steve
Hi Again Jim,
Im almost there with integrating Profit margin and Get 1 Free, no sql errors now, but is putting product_cost in order_products table as 0,
Not sure if i am calling the Get 1 free product id correctly, code below would appreciate if you could take a quick look, product_cost is in products table
Bold is lines ive added
// Get 1 free
// If this product qualifies for free product(s) add the free products
if (is_array ($free_product = $cart->get1free ($products_id))) {
// Update products_ordered (for bestsellers list)
// comment out the next line if you don't want free products in the bestseller list
tep_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $free_product['quantity']) . " where products_id = '" . tep_get_prid($free_product['id']) . "'");
$product_cost_query = tep_db_query("select products_cost from " . TABLE_PRODUCTS . " where products_id ='". tep_get_prid($free_product['id']). "'");
$product_cost = tep_db_fetch_array($product_cost_query);
$sql_data_array = array('orders_id' => $insert_id,
'products_id' => $free_product['id'],
'products_model' => $free_product['model'],
'products_name' => $free_product['name'],
'products_price' => 0,
'products_cost' => $product_cost['products_cost'],
'final_price' => 0,
'products_tax' => '',
'products_quantity' => $free_product['quantity']
);
tep_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);
$total_weight += ($free_product['quantity'] * $free_product['weight']);
}
// end Get 1 free
Thanks
Steve
Edited by steve_s, 10 April 2009, 16:05.