Question

I have Multistore website and now I want to enable Custom Shipping Method for Specific Store. How to I'll do this ?

Thanks

Was it helpful?

Solution

If you want to manage the Custom Shipping method enabled setting from Store view then you have to do small changes at system.xml of your Custom shipping method module.

At Magento Shipping method's enabled/Disabled setting managed at Default & website, then on system.xml you have to make showInStore="1" like showInDefault="1" or showInWebsite="1".

Example, you want to enable flat table at store view then

then you have to make to

    <group id="flatrate" translate="label" type="text" sortOrder="0" showInDefault="1" showInWebsite="1" showInStore="1">
        <label>Flat Rate</label>
        <field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
            <label>Enabled</label>
            <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
        </field>

From

    <group id="flatrate" translate="label" type="text" sortOrder="0" showInDefault="1" showInWebsite="1" showInStore="1">
        <label>Flat Rate</label>
        <field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
            <label>Enabled</label>
            <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
        </field>

Suppose, you don't want to directly modify the system.xml of your custom module, then create a new module which must depend on your custom module using <sequence> at module.xml then create system.xml at that new module and add below code:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <section id="carriers" type="text" sortOrder="320" showInDefault="1" showInWebsite="1" showInStore="1">
            <group id="flatrate" translate="label" type="text" sortOrder="0" showInDefault="1" showInWebsite="1" showInStore="1">
                <label>Flat Rate</label>
                <!--  here i make showInStore="0"  to showInStore="1"  -->
                <field id="active"  type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1" >
                </field>
            </group>
        </section>
    </system>
</config>

In the above example, I have enabled the flat rate for store view level.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top