I've bought this extension 'Buy one get one free'
http://www.opencart.com/index.php?route ... order=DESC
And it's a good extension, At X number of products you get the least expensive free.
The problem is it only deducts the base price - wich is a problem because the taxes are still added to the total. And in Romania (where I'm from) and in most EU countries that is illegal - you cannot charge tax on something you don't sell.
So I need a snippet of code that can calculate Dicount Price bassed on Tax Incl. Price.
something on the lines of this :
Code: Select all
if ( $product['tax_class_id'] == 7 )
$VAT = (1 + (9/100));
else $VAT *= (1 + (24/100));
Also, where should i put the code?
The author was not such a big help, he told me to put it here
Code: Select all
$prices = array();
foreach($total_products as $product) {
//INSERT CODE HERE
if ( $product['price'] > $MIN ) $prices[] = ($product['price']*$TVA);
}
$max_price = $prices;
for($i=0;$i<$discount_products_cnt;$i++) {
$max_price = min($prices);
foreach($total_products as $product) {
if ( $product['price'] == $max_price ) {
$discount_total += $product['price'];
$key = array_search($max_price, $prices);
unset($prices[$key]);
break 1;
}
}
}
Thanks