Jump to content

How to check hook in my module is works?


An'im Fahmy

Recommended Posts

How to check the hook is works?

 

This is my code

<?php
if (!defined('_PS_VERSION_'))
  exit;
 
class InagataModule extends Module
{
  public function __construct()
  {
    $this->name = 'inagatamodule';
    $this->tab = 'billing_invoicing';
    $this->version = '1.0.0';
    $this->author = "Achmad An'im Fahmy ";
    $this->need_instance = 0;
    $this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_); 
    $this->bootstrap = true;
 
    parent::__construct();
 
    $this->displayName = $this->l('Inagata Module');
    $this->description = $this->l('Mengirim push notification ketika status order berubah.');
 
    $this->confirmUninstall = $this->l('Are you sure you want to uninstall?');
 
    if (!Configuration::get('INAGATAMODULE'))      
      $this->warning = $this->l('No name provided');
  }
#displayBackOfficeHeader
public function install()
{
  if (Shop::isFeatureActive())
    Shop::setContext(Shop::CONTEXT_ALL);
 
  if (!parent::install() ||
    !$this->registerHook('actionOrderStatusPostUpdate') ||
    !Configuration::updateValue('INAGATAMODULE', 'my friend')
  )
    return false;
 
  return true;
}

public function uninstall()
{
  if (!parent::uninstall() ||
    !Configuration::deleteByName('INAGATAMODULE')
  )
    return false;
 
  return true;
}

public function hookactionOrderStatusPostUpdate($params)
{
  $file = 'coba';
// Open the file to get existing content
  $current = file_get_contents($params);
  // Append a new person to the file
  $current .= "$params\n";
  // Write the contents back to the file
  file_put_contents($file, $current);
  echo "<pre>".print_r($params)."</pre>";die();
}

}

in function hookactionOrderStatusPostUpdate not write anything to coba file and not print anything.

 

But, when I use standard hooks, it's showing in website (displayHeader)

 

Thank you

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