![]() |
Cart class & adding VAt @20% and delivery charges - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Cart class & adding VAt @20% and delivery charges (/showthread.php?tid=51862) Pages:
1
2
|
Cart class & adding VAt @20% and delivery charges - El Forum - 05-21-2012 [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-guide/libraries/cart.html but no I want to know what is the best way to achieve the above....?? Help greatly appreciated. Cart class & adding VAt @20% and delivery charges - El Forum - 05-21-2012 [eluser]the_unforgiven[/eluser] Anyone care to share....? Cart class & adding VAt @20% and delivery charges - El Forum - 05-21-2012 [eluser]weboap[/eluser] from : http://ellislab.com/codeigniter/user-guide/libraries/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] Cart class & adding VAt @20% and delivery charges - El Forum - 05-21-2012 [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 Cart class & adding VAt @20% and delivery charges - El Forum - 05-21-2012 [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. Cart class & adding VAt @20% and delivery charges - El Forum - 05-21-2012 [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. Cart class & adding VAt @20% and delivery charges - El Forum - 05-22-2012 [eluser]the_unforgiven[/eluser] Sweet thats exactly what I was after, much appreciated guys thankx Cart class & adding VAt @20% and delivery charges - El Forum - 05-22-2012 [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. Cart class & adding VAt @20% and delivery charges - El Forum - 05-22-2012 [eluser]dnc[/eluser] Will this work? Code: round(14.578); Cart class & adding VAt @20% and delivery charges - El Forum - 05-22-2012 [eluser]the_unforgiven[/eluser] kinda yer, but need it show for example: £14.58 instead of 14.578 |