Jump to content

Carrier status when module is disabled


fugasok

Recommended Posts

Hello

Having problem with a carrier module. When i disable module on module page it is still showing up as enabled in BackOffice->shipping->carriers and in front-office also.

What should i add to code to remove this problem?

When module is disabled on backoffice modules list page carrier status must be changed to disabled in Shipping -> carriers

Link to comment
Share on other sites

I figure out what to add in module php file.

If somebody will have same problem just insert this part of a code into your carrier module main fail (dont forget to change YOUR_MODULE_NAME

    public function disable($force_all = false)
    {
        $carriers = Carrier::getCarriers($this->context->language->id, true, false, false, null, Carrier::CARRIERS_MODULE);
        foreach ($carriers as $carrier) {
            if ($carrier['external_module_name'] == 'YOUR_MODULE_NAME') {
                $carrierObj = new Carrier($carrier['id_carrier']);
                $carrierObj->active = '0';
                $carrierObj->save();
            }
        }
        return parent::disable($force_all);
    }

    public function enable($force_all = false)
    {
        $carriers = Carrier::getCarriers($this->context->language->id, false, false, false, null, Carrier::CARRIERS_MODULE);
        foreach ($carriers as $carrier) {
            if ($carrier['external_module_name'] == 'YOUR_MODULE_NAME') {
                $carrierObj = new Carrier($carrier['id_carrier']);
                $carrierObj->active = '1';
                $carrierObj->save();
            }
        }
        return parent::enable($force_all);
    }

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...