From 3aa70ef59a5dc8d89c644da6ed6c8cfaf226b958 Mon Sep 17 00:00:00 2001 From: Julian van den Berkmortel Date: Thu, 10 Dec 2020 22:26:29 +0100 Subject: [PATCH 1/2] Use a layout processor rather than plugin in the "Customize the view of a checkout step" docs --- .../howdoi/checkout/checkout_customize.md | 41 ++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/src/guides/v2.3/howdoi/checkout/checkout_customize.md b/src/guides/v2.3/howdoi/checkout/checkout_customize.md index 695e26d08af..06287574a41 100755 --- a/src/guides/v2.3/howdoi/checkout/checkout_customize.md +++ b/src/guides/v2.3/howdoi/checkout/checkout_customize.md @@ -154,13 +154,44 @@ To disable the component in your `checkout_index_index.xml` use the following in ## Remove a component {#remove} -To remove a component from layout rendering, you need to create a [plugin]({{ page.baseurl }}/extension-dev-guide/plugins.html) for the `\Magento\Checkout\Block\Checkout\LayoutProcessor::process` method. In your plugin, implement the around method removing the corresponding layout nodes at run-time. +If you want to keep a component from being rendered, you need to create a layout processor. A layout processor consists of a class, implementing +the `\Magento\Checkout\Block\Checkout\LayoutProcessorInterface` interface, and thus a `LayoutProcessorInterface::process($jsLayout)` method. + +```php +\\Block\Checkout; + +use Magento\Checkout\Block\Checkout\LayoutProcessorInterface; + +class OurLayoutProcessor implements LayoutProcessorInterface +{ + /** + * @param array $jsLayout + * @return array + */ + public function process($jsLayout) + { + //%path_to_target_node% is the path to the component's node in checkout_index_index. + unset($jsLayout['components']['checkout']['children']['steps'][%path_to_target_node%]); + return $jsLayout; + } +} +``` -The following sample is an example of the around method removing a component: +Once created you can add the layout processor through Dependency Injection (DI). -```php?start_inline=1 -unset($jsLayout['components']['checkout']['children']['steps'][%path_to_target_node%]); //%path_to_target_node% is the path to the component's node in checkout_index_index.xml -return $jsLayout; +```xml + + + + + + \\Block\Checkout\OurLayoutProcessor + + + + ``` If you want to use this sample in your code, replace the `%path_to_target_node%` placeholder with real value. From 201603be1586ad566a352c89e7729c7f1acd8b37 Mon Sep 17 00:00:00 2001 From: Donald Booth Date: Mon, 4 Jan 2021 08:42:00 -0500 Subject: [PATCH 2/2] Grammar --- src/guides/v2.3/howdoi/checkout/checkout_customize.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/guides/v2.3/howdoi/checkout/checkout_customize.md b/src/guides/v2.3/howdoi/checkout/checkout_customize.md index 06287574a41..e258f985bca 100755 --- a/src/guides/v2.3/howdoi/checkout/checkout_customize.md +++ b/src/guides/v2.3/howdoi/checkout/checkout_customize.md @@ -154,7 +154,7 @@ To disable the component in your `checkout_index_index.xml` use the following in ## Remove a component {#remove} -If you want to keep a component from being rendered, you need to create a layout processor. A layout processor consists of a class, implementing +To keep a component from being rendered, create a layout processor. A layout processor consists of a class, implementing the `\Magento\Checkout\Block\Checkout\LayoutProcessorInterface` interface, and thus a `LayoutProcessorInterface::process($jsLayout)` method. ```php @@ -179,7 +179,7 @@ class OurLayoutProcessor implements LayoutProcessorInterface } ``` -Once created you can add the layout processor through Dependency Injection (DI). +Once created, add the layout processor through Dependency Injection (DI). ```xml @@ -194,7 +194,7 @@ Once created you can add the layout processor through Dependency Injection (DI). ``` -If you want to use this sample in your code, replace the `%path_to_target_node%` placeholder with real value. +To use this sample in your code, replace the `%path_to_target_node%` placeholder with real value. {:.bs-callout-info} -Disable vs remove a component: If you disable a component, it is loaded but not rendered. If you remove a component, it is removed and not loaded. +Disable vs remove a component: A disabled component is loaded but not rendered. If you remove a component, it is removed and not loaded.