Welcome Guest, Not a member yet? Register   Sign In
Cart class & adding VAt @20% and delivery charges
#1

[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.
#2

[eluser]the_unforgiven[/eluser]
Anyone care to share....?
#3

[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(
               'id'      => 'sku_123ABC',
               'qty'     => 1,
               'price'   => 39.95,
               'name'    => 'T-Shirt',
               'options' => array('Size' => 'L', 'Color' => 'Red')
            );

$this->cart->insert($data);


[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]
#4

[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
#5

[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.
#6

[eluser]dnc[/eluser]
Yes, I agree with weboap.

The way I would do this is

Code:
$data = array(
               'id'      => 'sku_123ABC',
               'qty'     => 1,
               'price'   => 100.00,
               'name'    => 'T-Shirt',
               'options' => array('Size' => 'L', 'Color' => 'Red', 'Vat' => '.20')
            );

$data['vat_included'] = $data['price'] * $data['options']['Vat'];


$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.
#7

[eluser]the_unforgiven[/eluser]
Sweet thats exactly what I was after, much appreciated guys thankx
#8

[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.
#9

[eluser]dnc[/eluser]
Will this work?

Code:
round(14.578);
#10

[eluser]the_unforgiven[/eluser]
kinda yer, but need it show for example: £14.58 instead of 14.578




Theme © iAndrew 2016 - Forum software by © MyBB