Cart class & adding VAt @20% and delivery charges |
[eluser]the_unforgiven[/eluser]
Just wondered what is the best way to add 20% VAT (UK BASED Business) and a delivery charge either flat fee or based on what is already in the cart? I have just used the standard class as per -> http://ellislab.com/codeigniter/user-gui.../cart.html but no I want to know what is the best way to achieve the above....?? Help greatly appreciated.
[eluser]weboap[/eluser]
from : http://ellislab.com/codeigniter/user-gui.../cart.html you can use the options array. to have something like 'vat'=> 20 then generating the invoice you can use that value, you store it to with the sell, that way in the future if the vat change your old orders doesn't mess up ... Code: $data = array( [quote] ....The fifth index (options) is optional. It is intended to be used in cases where your product has options associated with it. Use an array for options, as shown above.... [quote]
[eluser]the_unforgiven[/eluser]
But that will just add a value of 20 to the sum not 20 % right? I need it to add 20% percent
[eluser]weboap[/eluser]
i suggested to add an option to the item before inserting it to the cart and apply the vat at the checkout, after you pull the list of products in the cart doing the calc, with the ( $items['price'] * option_value/100 ) option_value will be the 20. then adding that to the subtotal $items['subtotal'], but yes that won't work somewhere there with too many items in the cart or want to calculate 1 value at the end of the invoice, another way will be to calculate 20% based on the $this->cart->total(). hope it help.
[eluser]dnc[/eluser]
Yes, I agree with weboap. The way I would do this is Code: $data = array( $vat_included will be the calculated tax on the items in the cart and simply find out if VAT is due and add $vat_included to the price for the total.
[eluser]the_unforgiven[/eluser]
Sweet thats exactly what I was after, much appreciated guys thankx
[eluser]the_unforgiven[/eluser]
I've done what you said with thanks again worked a treat, just one small thing - when i have the array options like so: Code: 'options' => array('Vat' => '.20'); I get a price like so: VAT @20% £1.598 Total £14.578 So it adds on a extra digit, which obviously I don't want or need...how does one get rid of this or even better round it up to the nearest.
[eluser]the_unforgiven[/eluser]
kinda yer, but need it show for example: £14.58 instead of 14.578 |
Welcome Guest, Not a member yet? Register Sign In |