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, ...

Get PrestaShop Module Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.