1

I need to remove Company field from checkout page. I am trying to follow this tutorials "Remove a component". But I am getting next Error:

Uncaught TypeError: Cannot read property 'indexedOptions' of undefined(…) region.js:59 

My Plugins file is:

public function aroundProcess(\Magento\Checkout\Block\Checkout\LayoutProcessor $subject, \Closure $proceed, $jsLayout) {
    unset($jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']
            ['children']['shippingAddress']['children']['shipping-address-fieldset']['children']['company']);
    return $jsLayout;
}

Can anyone explain me please what i am doing wrong?

1 Answer 1

1

I found the solution in this page https://github.com/magento/magento2/issues/4425

And the working code is:

public function aroundProcess(\Magento\Checkout\Block\Checkout\LayoutProcessor $subject, \Closure $proceed, $jsLayout) {
    $ret = $proceed($jsLayout);
    unset($ret['components']['checkout']['children']['steps']['children']['shipping-step']
            ['children']['shippingAddress']['children']['shipping-address-fieldset']['children']['company']);
    return $ret;
}

From this plugin documentation I found also the problem: "It is also worth noting that you are responsible for forwarding the arguments from the plugin to the proceed callable." I add the the plugin function signature from @Aaron Allen answer to my previous post so it would be more clearer to anyone who would be needing it.

function aroundMethod ($subject, \Closure $proceed, $arg1, $arg2, etc...)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.