定制 elgentos/vat-switcher 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱: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.24k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 15
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 15
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2023-01-25