Post by Schtrudahl » Sat Apr 07, 2012 5:22 pm

Hei mates,
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));
I have two rates, 9% and 24%. The id for 9% is 7 and for 24% is 8.

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;
 					}
				} 				
			}
But it didn't produce any results.

Thanks


Posts

Joined
Tue Jan 31, 2012 4:23 am

Post by Sebcart » Tue Apr 16, 2013 4:54 am

*kick*

I need this as well. If I offer 10% discount vouchers 1.5.5.1 calculates the discount over the price excl vat - which is not what I'm offering.. A 10 euro product should get 1 euro discount but the customer now only receives 83 cents discount..


Posts

Joined
Sat Sep 08, 2012 11:25 pm

Post by Sebcart » Tue Apr 16, 2013 1:09 pm

Found another topic with a solution; Just change the sort order in Admin under Extensions -> Order Totals so that VAT is shown after coupon instead of before. just too bad the discount still says 83 instead of 1 euro - but effectively that is what you see in the total price so at least it works


Posts

Joined
Sat Sep 08, 2012 11:25 pm
Who is online

Users browsing this forum: No registered users and 4 guests