• Resolved mkudro

    (@mkudro)


    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.

    https://www.ads-software.com/extend/plugins/eshop/

Viewing 13 replies - 1 through 13 (of 13 total)
  • Of course I may take that code and add it into the core, many thanks.

    copied for future use.

    Nice! It does show beautifully in the cart… BUT, yes there is a big bad BUTT..

    The email confirmation and the back-end orders console DOES NOT register the actual amount of VAT at all..

    test here: demosite.beththeimva.com

    I’m sratching my head with this one… for 1. i am a PHP Noob… I disregarded getting into it because other things demand my attention…

    2. I really hate messing up code before someone whose done it can share some pointers and point me into the correct direction right away… so uhm Mkurdo… (assuming you are dutch, rest is in dutch) Zou je mij een handje willen helpen? Wij gaan geen payment gateway gebruiken, Payment Upon Delivery till further notice. DUS… het is van belang dat de klanten een email confirmation ontvangen dat het correcte bedrag vermeldt.

    And to Elfin: Any way I can let the order confirm also go to a business address every time? To alert the company that they have to go, order and deliver…

    Let me know!

    please don’t aks questions in resolved threads – thanks.

    Please don’t be like that the initial poster said ask me if there’s anything.

    That you decided it was resolved when there was no problem is NOT my problem. If you don’t want to help out then don’t but don’t tell me I can’t ask here because I quote:

    mkurdo said:

    please let me know if something is unclear. I will do my best to help.

    Plus you still might be no help all the other tax questions you shot down with it doesn’t feature this setting, end.

    Way to help people that use your plugin…

    elfin: just scrap the part I ask you for help.. posted the question elsewhere..

    ??

    That you decided it was resolved when there was no problem is NOT my problem. If you don’t want to help out then don’t but don’t tell me I can’t ask here because

    only topic starters and forum moderators can mark topics as resolved.

    uhh.. k but I was asking mrkurdo who said to ask him…

    I still am asking HIM..

    And to Elfin: Any way I can let the order confirm also go to a business address every time? To alert the company that they have to go, order and deliver…

    elfin: just scrap the part I ask you for help.. posted the question elsewhere..

    ??

    Did we not already get the answer to that in the other post? the “it’s probably delayed or something”?

    Okay, so mkurdo? any tips on the part about the confirmation email not showing the total with the vat in it?

    Thanks a bunch when you finally answer.

    This was a great help but only works if you buy one product. If you have more than one, it only calculates the tax of one product.

    Any help would be very appreciated.

    I wonder if there is a way to use this work-around to detect country/state and apply a specific tax rate for that country/state. For example, if a customer purchases a product any they live in state X then X tax rate is applied and if they live in state Y then Y rate is applied.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘[Plugin: eShop] VAT/TAX for eSHOP plugin’ is closed to new replies.