cancel
Showing results for 
Search instead for 
Did you mean: 

Checkout remove VAT when currency is USD

Checkout remove VAT when currency is USD

Hello,

We have a UK site where on the category/product page with GBP as the default, it displays IncVAT and Excl VAT when selecting USD as the currency I have managed to hide the Excl VAT

on both pages, which is fine, I'm trying to achieve the same on the checkout after investigating, it looks like it uses KO Js, something I have never used! and is creating a symlink in

pub/static/frontend/theme/base_theme/en_GB/Magento_Tax/template/checkout/summary/tax.html

to

vendor/magento/module-tax/view/frontend/web/template/checkout/summary/tax.html

Which has the following code, which I want to hide if the USD currency is selected.

 
<!-- ko if: ifShowValue() && !ifShowDetails() -->
<tr class="totals-tax">
    <th data-bind="text: title" class="mark" scope="row"></th>
    <td data-bind="attr: {'data-th': title}" class="amount">
        <!-- ko if: isCalculated() -->
            <span class="price"
                  data-bind="text: getValue()"></span>
        <!-- /ko -->
        <!-- ko ifnot: isCalculated() -->
            <span class="not-calculated"
                  data-bind="text: getValue()"></span>
        <!-- /ko -->
    </td>
</tr>
<!-- /ko -->
 


Does anybody know, what code to write to hide this when USD is selected, any help appreciated

 

Regards

Mal

2 REPLIES 2

Re: Checkout remove VAT when currency is USD

Ideally you should have 2 different store views, 1 for UK/GBP and another for US/USD. The currency switcher should switch between those two store views.

 

Then in Stores > Configuration > Sales > Tax > Price Display Settings > Set "Display Product Prices In Catalog" to Including tax for UK/GBP store view and Excluding tax for US/USD store view.

Founder at https://agency418.com

Re: Checkout remove VAT when currency is USD

Hi @mallongstoaf62,

 

To programmatically adjust the display of VAT in the checkout when the currency is USD in Magento (Adobe Commerce), you can use a custom module and observer to modify the tax display logic. Here's a general guide to achieve this:

 

Step 1: Create a Custom Module
In your Magento installation, create a new module. You can create the necessary files and folders manually or use a module generator tool.

For example, create the following files:

 

app/code/[Vendor]/[Module]/registration.php
app/code/[Vendor]/[Module]/etc/module.xml
app/code/[Vendor]/[Module]/etc/events.xml
app/code/[Vendor]/[Module]/Observer/AdjustVatDisplay.php

In registration.php, register your module:

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    '[Vendor]_[Module]',
    __DIR__
);

In module.xml, declare your module:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="[Vendor]_[Module]" setup_version="1.0.0">
        <sequence>
            <module name="Magento_Checkout" />
        </sequence>
    </module>
</config>

Step 2: Create an Observer
In events.xml, define the event observer:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="checkout_layout_render_before">
        <observer name="[vendor]_[module]_observer" instance="[Vendor]\[Module]\Observer\AdjustVatDisplay" />
    </event>
</config>

. In AdjustVatDisplay.php, implement the observer logic:

<?php
namespace [Vendor]\[Module]\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Store\Model\StoreManagerInterface;

class AdjustVatDisplay implements ObserverInterface
{
    protected $storeManager;
    public function __construct(
        StoreManagerInterface $storeManager
    ) {
        $this->storeManager = $storeManager;
    }
    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $layout = $observer->getLayout();
        $storeId = $this->storeManager->getStore()->getId();
        $currentCurrencyCode = $this->storeManager->getStore($storeId)->getCurrentCurrencyCode();

        // Check if the current currency is USD
        if ($currentCurrencyCode == 'USD') {
            // Example: hide VAT on the checkout page
            $block = $layout->getBlock('checkout.cart.summary');
            if ($block) {
                $vatBlock = $block->getChildBlock('tax');
                if ($vatBlock) {
                    $vatBlock->setData('is_vat_visible', false);
                }
            }
        }
    }
}

Step 3: Clear Cache
After implementing the module and observer, clear the Magento cache:
php bin/magento cache:clean

If the issue will be resolved, Click Kudos & Accept as a Solution.