Creating a Carrier programmatically
As seen in the previous sections, even if our Carrier
module could simply manage an existing Carrier
(created manually via the BO), we prefer to create our Carrier
programmatically directly on install()
via an installCarrier()
method. It will enable us to have everything available.
Let’s do it directly by explaining the following code of our installCarrier()
:
public function installCarrier() { $carrier = new Carrier(); $carrier->name = "Relay Carrier"; $carrier->url = "https://www.domainname.ext/follow/@"; $carrier->delay[Configuration::get('PS_LANG_DEFAULT')] = "24 hours"; $carrier->is_free = false; $carrier->active = true; $carrier->deleted = false; $carrier->shipping_handling = false; //Highest defined range if false, true to disable ...