elgentos / vat-switcher
elgentos/vat-switcher
Vat switcher to let customer decide on how to show their prices
#Hyva VatSwitcher
Adds a vat switcher to the header component to let customer decide on how
to show their prices; including or excluding VAT. The decision is saved to
the browser storage.
Because there are a lot of prices in magento, there is a reusable alpine
component to switch between prices realtime. It only needs the including
and excluding price.
###Example with alpine component
<div x-data="initVatSwitcherPrice()" x-spread="eventListeners">
<span class="price-incl" x-show="vatMode == 'including'" x-html="hyva.formatPrice('<?= $priceModel->getValue() ?>')"></span>
<span class="price-excl" x-show="vatMode == 'excluding'" x-html="hyva.formatPrice('<?= $priceModel->getBaseAmount() ?>')"></span>
</div>
<script>
function initVatSwitcherPrice() {
return {
vatMode: vatSwitcher.getVatMode(),
eventListeners: {
['@vat-switched.window'](event) {
this.vatMode = event.detail;
}
}
}
}
</script>
###Example with existing alpine component
Sometimes you will need price info from an already existing price component,
because it is hard to pass data from parent to child components in alpine. In
this case you can simply add the vatmode: vatMode: vatSwitcher.getVatMode(),
and the eventListener to the existing component:
function initExistingComponent() {
return {
vatMode: vatSwitcher.getVatMode(),
eventListeners: {
['@vat-switched.window'](event) {
this.vatMode = event.detail;
}
}
}
}
And make sure the existing component uses: x-spread="eventListeners". No you
can also use code like this in your existing component:
<div x-data="initExistingComponent()" x-spread="eventListeners">
<span class="price-incl" x-show="vatMode == 'including'" x-html="hyva.formatPrice('<?= $priceModel->getValue() ?>')"></span>
<span class="price-excl" x-show="vatMode == 'excluding'" x-html="hyva.formatPrice('<?= $priceModel->getBaseAmount() ?>')"></span>
</div>
No changelog yet
The vendor hasn't published a changelog. Tagged releases appear in the Versions tab.
Requires 1
| Package | Constraint |
|---|---|
| hyva-themes/magento2-theme-module | >=1.1 |
Compatibility
Each Magento release line is installed on its supported PHP versions, then the module is built (DI compilation + static-content deploy) and its unit and integration suites are run. The matrix shows the lines and PHP versions the module is confirmed to install and run on. Code-quality results further down (phpstan, phpcs, …) are reported separately and never affect compatibility.
Code Quality
Advisory checks against the module's source. Static analysis runs once across the whole module; PHPStan re-runs per Magento + PHP version because resolvable symbols differ between releases. These NEVER affect the Compatibility badge — a phpcs finding can't make a module incompatible.
Static analysis
Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.
PHPStan
Type-checks the module's PHP against a real Magento install at the configured gate level. Re-runs per Magento and PHP version because resolvable symbols differ between releases. Cell → details modal.
Tests
Unit and integration suites, run for each applicable Magento and PHP version. A test failure speaks to the module's behaviour, not its compatibility with a Magento line, so it is reported here separately and never reddens the compatibility matrix.
Unit tests
| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | ||
| 2.4.8 | N/A | N/A | ||
| 2.4.9 | N/A | N/A |
Integration tests
| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | ||
| 2.4.8 | N/A | N/A | ||
| 2.4.9 | N/A | N/A |
Security
Security checks run directly against the module: an audit of its declared dependencies for known vulnerabilities (composer audit) and a scan of its source for malware and web-shell signatures. Each runs once. A malware detection fails the version outright.
More from elgentos
View vendorLink existing guest orders to newly created or existing customer based on e-mail address
Allows customers to enter a secondary email address to login with
Hide Mollie payment methods based on category
Turn an existing module into recurring revenue.
If you already maintain a Magento 2 module on GitHub or GitLab, listing it on Packagento takes about five minutes. We mirror your tags, handle distribution signing, and route paid licenses through Stripe Connect, so you can keep shipping the way you already do.