2

I am trying to follow this tutorials "Remove a component" But getting next Error:

"Uncaught Error: Cannot use object of type Magento\Checkout\Block\Checkout\LayoutProcessor\Interceptor as array in".

The plugins code is:

class removeCheckoutComponent {
    public function aroundProcess($jsLayout) {
        unset($jsLayout['components']['checkout']['children']['steps']['%path_to_target_node%']); 
        return $jsLayout;
    }
}

Why it is not working? The end result I am trying to achieve is to remove city selection from checkout page.

3

The problem is you're not use the correct signature. Around plugins follow this signature:

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

Where $subject is the instance of the class whose method is being intercepted, $proceed is a delegate for the method, and then the arguments to the method call follow.

For your use case, you should have:

function aroundProcess (\Magento\Checkout\Block\Checkout\LayoutProcessor $subject, \Closure $proceed, $jsLayout)
{
    unset($jsLayout['components']['checkout']['children']['steps']['%path_to_target_node%']);
    return $proceed($jsLayout);
}

More info here: http://devdocs.magento.com/guides/v2.0/extension-dev-guide/plugins.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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