[Plugin: eShop] VAT/TAX for eSHOP plugin
-
for people who are missing the VAT or tax future in eshop. i did some hacking of cart-function.php and implemented vat calculation. Now it calculates tax on total items purchased and if there is any discount then discount is calculated on price including vat.
But remember this requires for you caution if you decide to upgrade eshop. And because this is a workaround you will require to do hacking all over again id upgrade of eshop overwrites cart-functions.php.Oh yeah…i did this workaround for single country/state case.
step 1
introduce VAT into cart-functions.php
obviously you can choose any vat you wish. 1.19 is vat that is added in Netherlands<?php if ('cart-functions.php' == basename($_SERVER['SCRIPT_FILENAME'])) die ('<h2>'.__('Direct File Access Prohibited','eshop').'</h2>'); if (!function_exists('display_cart')) { function display_cart($shopcart, $change, $eshopcheckout,$pzone='',$shiparray=''){ //The cart display. global $wpdb, $blog_id; $echo =''; $check=0; $sub_total=0; $vat=1.19; //HERE INTRODUCING VAT $tempshiparray=array(); //this checks for an empty cart, may not be required but leaving in just in case. foreach ($_SESSION['shopcart'.$blog_id] as $productid => $opt){ .................... ....................
step 2
In the discount section (approximately on the line 113) i have introduced variable $inc_vat (stands for ‘including vat’).
/* DISCOUNT */ $opt["price"]+=$addoprice; $line_total=$opt["price"]*$opt["qty"]; $inc_vat=$line_total*$vat; //INTRODUCING INC_VAT ................... ...................
step 3
My disc_line of course would look different. This what i had to change:
In the same Discount section, just couple of lines under where i introduced inc_vat
$inc_vat=$line_total*$vat;
if(is_discountable(calculate_total())>0){
$discount=is_discountable(calculate_total())/100;
$disc_line= round($inc_vat – ($inc_vat * $discount), 2);
}<strong>step 4</strong> Couple of lines later there is calculation for sub_total. It changed from original this way:
if(isset($disc_line))
$sub_total+=$disc_line;
else
$sub_total+=$inc_vat;<strong>step 5</strong> An for a last step i added table (well section to table) so buyers could see something like - Total price including VAT ... In the section where subtotal row is displayd (aproximatly line 128) i added following:
// display subtotal row – total for products only
//implementing vat
$echo.= “<tr class=\”incvat\”><th id=\”totalvat\” class=\”leftb\”>”.__(‘Total inc 19% VAT’,’eshop’).’ ‘.”</th><td headers=\”subtotal cartTotal\” class=\”amts lb\” colspan=\”2\”>”.sprintf( _c(‘%1$s%2$s|1-curren cy symbol 2-amount’,’eshop’), $currsymbol, number_format($inc_vat,2)).”</td></tr>\n”;
………………
………………
`please let me know if something is unclear. I will do my best to help.
- The topic ‘[Plugin: eShop] VAT/TAX for eSHOP plugin’ is closed to new replies.