Community Forums

[NEED] BOGOF - Tax incl. 'Discount Price' Code

Support for Order Total extensions

[NEED] BOGOF - Tax incl. 'Discount Price' Code

Postby Schtrudahl » Sat Apr 07, 2012 4:22 am

Hei mates,
I've bought this extension 'Buy one get one free'
http://www.opencart.com/index.php?route=extension/extension/info&extension_id=4865&filter_search=bogof&sort=e.date_modified&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
Schtrudahl
 
Posts: 10
Joined: Mon Jan 30, 2012 3:23 pm

Re: [NEED] BOGOF - Tax incl. 'Discount Price' Code

Postby Sebcart » Mon Apr 15, 2013 3:54 pm

*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..
Sebcart
 
Posts: 26
Joined: Sat Sep 08, 2012 10:25 am

Re: [NEED] BOGOF - Tax incl. 'Discount Price' Code

Postby Sebcart » Tue Apr 16, 2013 12:09 am

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
Sebcart
 
Posts: 26
Joined: Sat Sep 08, 2012 10:25 am


Return to Order Totals

Who is online

Users browsing this forum: No registered users and 2 guests

Hosted by Arvixe Web Hosting