首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Magneto 2-删除相同发货地址和账单地址的默认复选框

Magneto 2-删除相同发货地址和账单地址的默认复选框
EN

Stack Overflow用户
提问于 2021-12-20 07:30:42
回答 2查看 977关注 0票数 0

由于有很多关于相同的问题,而且也已经验证了答案,但它不能解决我的问题,因为我想从结账页面中删除默认的检查,我将使用Amasty页面结帐任何帮助将不胜感激。谢谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-01-07 02:35:45

覆盖:

vendor/magento/module-checkout/view/frontend/web/template/billing-address.html

在您的自定义主题中:

app/design/frontend///Magento_Checkout/web/template/billing-address.html

并删除:

代码语言:javascript
复制
<div class="billing-address-same-as-shipping-block field choice" data-bind="visible: canUseShippingAddress()">
    <input type="checkbox" name="billing-address-same-as-shipping"
           data-bind="checked: isAddressSameAsShipping, click: useShippingAddress, attr: {id: 'billing-address-same-as-shipping-' + getCode($parent)}"/>
    <label data-bind="attr: {for: 'billing-address-same-as-shipping-' + getCode($parent)}"><span
            data-bind="i18n: 'My billing and shipping address are the same'"></span></label>
</div>
票数 0
EN

Stack Overflow用户

发布于 2022-08-12 10:35:02

我的Magento版本是2.4

而不是覆盖核心js文件,我使用Js密辛方式来实现输出,见下图。

创建Vendor\Module\view\frontend\web\js\view\checkout\billing-address-mixin.js的

代码语言:javascript
复制
define([
    'jquery',
    'ko',
    'underscore',
    'uiRegistry',
    'Magento_Checkout/js/model/quote',
], function (
    $,
    ko,
    _,
    registry,
    quote,
    ) {
    'use strict';

    var mixin = {
        
        /**
         * on change billing address set `isAddressSameAsShipping` variable as a "false" for display Edit Button below the Address 
         * 
         * see /Magento_Checkout/view/frontend/web/template/billing-address/details.html template file 
         */
        initObservable: function () {
            var result = this._super();

            quote.billingAddress.subscribe(function (newAddress) {
                this.isAddressSameAsShipping(false);
            }, this);

            return result;
        },

        /**
         * return false for hide the `My billing and shipping address are the same` checkbox 
         * 
         * see /Magento_Checkout/view/frontend/web/template/billing-address.html template file
         */
        canUseShippingAddress: ko.computed(function () {
            return false;
        }),

    }

    return function (target) {
        return target.extend(mixin);
    };
});

&然后创建Vendor\Module\view\frontend\requirejs-config.js

代码语言:javascript
复制
var config = {
    config: {
        mixins: {         
            'Magento_Checkout/js/view/billing-address': {
                'Vendor_Module/js/view/checkout/billing-address-mixin': true
            },
        }
    },
}

输出:-

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70418624

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档