Book Image

PrestaShop Module Development

By : Fabien Serny
Book Image

PrestaShop Module Development

By: Fabien Serny

Overview of this book

Table of Contents (19 chapters)
PrestaShop Module Development
About the Author
About the Reviewers

Displaying the customer's choice in the back office

You've reached the last part of this chapter (don't worry, it's the easiest part).

In the install method of your module, attach your module to the displayAdminOrder hook (do not forget to uninstall/reinstall your module once done).

Next, as for the other hooks, create a controller named displayAdminOrder. In this controller, first check whether the carrier selected is the one with the relay point. Then, retrieve the choice of the customer with the cart ID by using the method we created in the previous section, getRelayPointByCartId.

Finally, assign the object to Smarty. At the end, you should have something like this:

public function run()
  // Check if selected carrier is relay point carrier
  $order = new Order((int)Tools::getValue('id_order'));
  if ($order->id_carrier != Configuration::get('MYMOD_CA_REPO'))
    return '';

  // Retrieve relay point cart association
  $id_cart = (int)$order->id_cart;
  $relaypoint = MyModCarrierRelayPoint...