Jump to content

[SOLVED] No tax on virtual products


Recommended Posts

One problem (of many) I'm working around in PrestaShop is how to sell gift cards without tax. The products are set to virtual, but PrestaShop still includes them in the total tax calculation. To fix this, in classes/Cart.php in the function getOrderTotal(), change this bit of code:

if ($with_taxes)
{
    $product_tax_rate = (float)Tax::getProductTaxRate((int)$product['id_product'], (int)$address_id, $virtual_context);
    $product_eco_tax_rate = Tax::getProductEcotaxRate((int)$address_id);

    $total_price = ($total_price - $total_ecotax) * (1 + $product_tax_rate / 100);
    $total_ecotax = $total_ecotax * (1 + $product_eco_tax_rate / 100);
    $total_price = Tools::ps_round($total_price + $total_ecotax, 2);
}

With this:

if ($with_taxes)
{
    // ben 
    $product_tax_rate = 0;
    if (empty($product['is_virtual']))
        $product_tax_rate = (float)Tax::getProductTaxRate((int)$product['id_product'], (int)$address_id, $virtual_context);
    $product_eco_tax_rate = Tax::getProductEcotaxRate((int)$address_id);

    $total_price = ($total_price - $total_ecotax) * (1 + $product_tax_rate / 100);
    $total_ecotax = $total_ecotax * (1 + $product_eco_tax_rate / 100);
    $total_price = Tools::ps_round($total_price + $total_ecotax, 2);
}

That worked for me, at least.

 

-- Ben

Edited by BenLivingston (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...