elgentos/vat-switcher 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

elgentos/vat-switcher

最新稳定版本:0.1.0

Composer 安装命令:

composer require elgentos/vat-switcher

包简介

Vat switcher to let customer decide on how to show their prices

README 文档

README

Adds a B2B 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-switch.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-switch.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>

统计信息

  • 总下载量: 8.2k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 14
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 14
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固