Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 3541718

Browse files
authored
Merge branch 'master' into patch-2
2 parents 5bc5216 + 36ab859 commit 3541718

File tree

1 file changed

+38
-7
lines changed

1 file changed

+38
-7
lines changed

src/guides/v2.3/howdoi/checkout/checkout_customize.md

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,47 @@ To disable the component in your `checkout_index_index.xml` use the following in
154154

155155
## Remove a component {#remove}
156156

157-
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.
157+
To keep a component from being rendered, create a layout processor. A layout processor consists of a class, implementing
158+
the `\Magento\Checkout\Block\Checkout\LayoutProcessorInterface` interface, and thus a `LayoutProcessorInterface::process($jsLayout)` method.
159+
160+
```php
161+
<?php
162+
163+
namespace <Vendor>\<Module>\Block\Checkout;
164+
165+
use Magento\Checkout\Block\Checkout\LayoutProcessorInterface;
166+
167+
class OurLayoutProcessor implements LayoutProcessorInterface
168+
{
169+
/**
170+
* @param array $jsLayout
171+
* @return array
172+
*/
173+
public function process($jsLayout)
174+
{
175+
//%path_to_target_node% is the path to the component's node in checkout_index_index.
176+
unset($jsLayout['components']['checkout']['children']['steps'][%path_to_target_node%]);
177+
return $jsLayout;
178+
}
179+
}
180+
```
158181

159-
The following sample is an example of the around method removing a component:
182+
Once created, add the layout processor through Dependency Injection (DI).
160183

161-
```php?start_inline=1
162-
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
163-
return $jsLayout;
184+
```xml
185+
<?xml version="1.0"?>
186+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
187+
<type name="Magento\Checkout\Block\Onepage">
188+
<arguments>
189+
<argument name="layoutProcessors" xsi:type="array">
190+
<item name="ourLayoutProcessor" xsi:type="object"><Vendor>\<Module>\Block\Checkout\OurLayoutProcessor</item>
191+
</argument>
192+
</arguments>
193+
</type>
194+
</config>
164195
```
165196

166-
If you want to use this sample in your code, replace the `%path_to_target_node%` placeholder with real value.
197+
To use this sample in your code, replace the `%path_to_target_node%` placeholder with real value.
167198

168199
{:.bs-callout-info}
169-
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.
200+
Disable vs remove a component: A disabled component is loaded but not rendered. If you remove a component, it is removed and not loaded.

0 commit comments

Comments
 (0)