Creating new carriers
Now that we have a working configuration form, we will have to create carriers. In our case, we will create two carriers, one with a classic delivery option and one with relay points.
If you don't know how a carrier works in PrestaShop, I first invite you to create some carriers manually in your administration panel. This will help you understand the method described in the upcoming code.
We will first add the install
method in our module's main class, in which we will call a method named installCarriers
:
public function install() { if (!parent::install()) return false; if (!$this->installCarriers()) return false; return true; }
Unfortunately, there is no native method to create carriers, even in the CarrierModule
class. So, we will have to create the method ourselves. We will build it step by step:
First, create the
installCarriers
method:public function installCarriers() { }
Next, in this new function, retrieve the ID of the default language:
$id_lang_default...