Overriding settings via the XML layout

Most settings of the LokiCheckout are configured in the Magento Admin Panel under Stores > Configuration > Loki > Loki Checkout. But sometimes you want a setting to be fixed by your theme or module, or you want a setting to differ per layout handle (for instance, per skin). For this, the core module LokiCheckout_Core allows you to override most of its settings via the XML layout.

The loki-checkout.config block

The layout handle loki_checkout (file LokiCheckout_Core::layout/loki_checkout.xml) defines a non-rendering block loki-checkout.config with an empty array argument config:

<block name="loki-checkout.config" class="Magento\Framework\View\Element\Text">
    <arguments>
        <argument name="config" xsi:type="array"/>
    </arguments>
</block>

By adding items to this config argument, you can override settings. The name of each item is the configuration path; the value of each item is the value to use instead of the Store Configuration value.

Example: Disabling the "same as billing" behaviour

For instance, to disable the setting Field settings > Enable Same As Billing Checkbox (loki_checkout/fields/enable_same_as_billing), add the following to a file view/frontend/layout/loki_checkout.xml in your own module or theme:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:View/Layout:etc/page_configuration.xsd">
    <body>
        <referenceBlock name="loki-checkout.config">
            <arguments>
                <argument name="config" xsi:type="array">
                    <item name="loki_checkout/fields/enable_same_as_billing" xsi:type="boolean">false</item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

With this, LokiCheckout\Core\Util\SameAddressService::isEnabled() returns false, so the shipping address is no longer regarded (and copied) as billing address and the billing address form is used instead.

The checkbox block loki-checkout.billing.address.shipping-as-billing is added with the XML attribute ifconfig="loki_checkout/fields/enable_same_as_billing". Magento evaluates ifconfig against the Store Configuration, not against the loki-checkout.config block. If the Store Configuration value is still enabled, the checkbox is still rendered (but it no longer has any effect). To hide it as well, remove the block.

To also get rid of the checkbox itself, add the following to view/frontend/layout/loki_checkout_block_billing_address.xml:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:View/Layout:etc/page_configuration.xsd">
    <body>
        <referenceBlock name="loki-checkout.billing.address.shipping-as-billing" remove="true"/>
    </body>
</page>

Note that the module LokiCheckout_BillingFirst adds a similar block loki-checkout.shipping.address.billing-as-shipping with the same ifconfig attribute, so when using that module, remove that block instead.

Example: Multiple settings at once

Multiple items can be added at once. Use the right xsi:type for the value (boolean, number, string):

<referenceBlock name="loki-checkout.config">
    <arguments>
        <argument name="config" xsi:type="array">
            <item name="loki_checkout/fields/enable_same_as_billing" xsi:type="boolean">false</item>
            <item name="loki_checkout/fields/hide_region_when_optional" xsi:type="boolean">true</item>
            <item name="loki_checkout/cart/max_items_visible_count" xsi:type="number">5</item>
            <item name="loki_checkout/newsletter/default_value" xsi:type="boolean">false</item>
        </argument>
    </arguments>
</referenceBlock>

Example: A setting per skin

Because this is regular XML layout, you can put the override in any layout handle that is loaded in the checkout. For instance, the core adds a handle loki_checkout_skin_SKIN for the current skin (like loki_checkout_skin_default and loki_checkout_skin_onestep). To select the first shipping method automatically only with the One Step skin, add a file view/frontend/layout/loki_checkout_skin_onestep.xml:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:View/Layout:etc/page_configuration.xsd">
    <body>
        <referenceBlock name="loki-checkout.config">
            <arguments>
                <argument name="config" xsi:type="array">
                    <item name="loki_checkout/shipping/select_default_shipping_method" xsi:type="boolean">true</item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

Which settings can be overridden?

Only settings that are read via the getValue() method of the class LokiCheckout\Core\Config\Config can be overridden. At this moment, these are:

| Configuration path | Admin label | Config method | |---|---|---| | loki_checkout/fields/enable_same_as_billing | Enable Same As Billing Checkbox | enableSameAsBilling() | | loki_checkout/fields/enable_vat_id_only_for_company | Enable Vat ID Only For Companies | enableVatIdOnlyForCompany() | | loki_checkout/fields/hide_region_when_optional | Hide Region When Optional | hideRegionWhenOptional() | | loki_checkout/fields/capitalize_country_in_preview | Capitalize Country In Address Preview | capitalizeCountryInPreview() | | loki_checkout/shipping/select_default_shipping_method | Select Default Shipping Method | selectDefaultShippingMethod() | | loki_checkout/billing/select_default_payment_method | Select Default Payment Method | selectDefaultPaymentMethod() | | loki_checkout/newsletter/default_value | Subscribe by default | isNewsletterCheckedByDefault() | | loki_checkout/cart/max_items_visible_count | Maximum items visible | getMaxCartItemsToShowByDefault() | | loki_checkout/debug/enable | Enable Debugging | isDebug() | | loki_checkout/debug/html_hints | Add Hints to HTML Output | addHtmlHints() | | loki_checkout/debug/debug_block | Add Debug Block | addDebugBlock() | | checkout/options/max_items_display_count | (Magento core setting) | getMaxCartItemsToDisplay() |

The following settings can not be overridden this way, because they are read directly from the Store Configuration, and because they are needed before the layout is loaded:

  • loki_checkout/general/enable (Enable)
  • loki_checkout/general/license_key (License Key)
  • loki_checkout/general/theme (Skin)
  • loki_checkout/general/grid_layout (Address Grid Layout)

To use a different grid layout for a specific address form, use the block argument grid_layout instead (see Changing the grid of field blocks).

How it works

  • The class LokiCheckout\Core\Config\LayoutConfig holds the overrides. Its constant LayoutConfig::BLOCK_NAME contains the block name loki-checkout.config.
  • The observer LokiCheckout\Core\Observer\LoadLayoutConfig listens to the event layout_generate_blocks_after (in etc/frontend/events.xml) and calls LayoutConfig::loadFromLayout(), which reads the config argument of the block.
  • LokiCheckout\Core\Config\Config::getValue() first checks LayoutConfig::has($path). If the path is present, that value is returned. Otherwise, the Store Configuration value (store scope) is returned.

Some consequences of this:

  • Overrides only apply once the layout has been generated. When no layout is generated (or the layout does not contain the block), the Store Configuration value is used.
  • Code that reads the same path directly via Magento\Framework\App\Config\ScopeConfigInterface (including ifconfig attributes in the XML layout) does not see the override. In your own code, use the methods of LokiCheckout\Core\Config\Config instead to pick up overrides.
  • Other LokiCheckout modules with their own configuration class are not affected by this block, unless they use LokiCheckout\Core\Config\Config.

This feature was added to LokiCheckout_Core recently. If the class LokiCheckoutCoreConfigLayoutConfig does not exist in your installation, upgrade the module first.

Last modified: November 11, 2026