I have created configuration for enable/disable module. If I select "Yes" from configuration settings, my module is visible for front otherwise not. For this , I have added ifConfig condition in checkout_cart_index.xml. The xml code is given below.
<referenceContainer name="cart.summary">
<block class="Mageniks\Test\Block\Test" before="-" ifconfig="mageniks/general/active" name="displaytest" template="Mageniks_Test::cart.phtml">
</block>
</referenceContainer>
<referenceBlock name="checkout.cart.totals">
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
<item name="block-totals" xsi:type="array">
<item name="children" xsi:type="array">
<item name="fee" xsi:type="array" remove="true">
<item name="component" xsi:type="string">Mageniks_Test/js/view/checkout/cart/totals/fee</item>
<item name="sortOrder" xsi:type="string">20</item>
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">Mageniks_Test/checkout/cart/totals/fee</item>
<item name="title" xsi:type="string" translate="true">Fee</item>
</item>
</item>
</item>
</item>
</item>
</argument>
</arguments>
</referenceBlock>
Ifconfig is working only when block used. Ifconfig is not working in arguments.
I want to add condition in argument or item tag for enable and disable module like block tag.
How can I do this ? Please help me. Any help would be appreciated.
Thanks
Override theme layouts * To override page layout files, use the page_layout directory name instead of layout . * Remember to always name your new layout files with the same name as the file that you wish to override.
For example, the configuration object for config. xml is Magento\Framework\App\Config.
resource – defines the ACL rule which the admin user must have in order to see and access this menu, it is defined in acl. xml. Otherwise, menu item won't be rendered.
Using this pulgin you can put module enable disable condition in items
<type name="Magento\Checkout\Block\Cart\LayoutProcessor">
<plugin name="CartStorecreditDisable"
type="Vendor\Module\Plugin\CartStorecreditDisable"/>
</type>
In plugin,
use Magento\Checkout\Block\Cart\LayoutProcessor;
public function afterProcess(
LayoutProcessor $processor,
array $jsLayout
){
$enable = $this->helper->getConfig('storecredit/general/enable');
if($enable == 0){
$jsLayout['components']['block-totals']['children']['storecredit']['config']['componentDisabled'] = true;
}
return $jsLayout;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With