Jump to content

Retrieve order reference on a module


Recommended Posts

Hi... I am developing a very simple module. I want a module hooked to order confirmation that retrieves the order reference and prints it on the order confirmation screen, just as the cheque or bankwire modules work.

 

Something like this...

 

"Your reference is NH8V123, thanks for shopping with us"

 

The issue is I can´t retrieve from the context, or whatever, and assign to a smarty variable the order reference to print it out on the tpl module hooked to the order confirmation.

 

The main purpose of it is using the order confirmation hook available at the paypal module confirmation window to print this reference, since it is not printed by default.

 

Any idea?

 

Thank you very much.

Link to comment
Share on other sites

Hi Bellini. Thank you very much for answering. I used the code you provided me. However I get this errors:
 
Notice: Undefined index: objOrder in D:\xampp\htdocs\tkn1531a\modules\printref\printref.php on line 38

Notice: Trying to get property of non-object in D:\xampp\htdocs\tkn1531a\modules\printref\printref.php on line 38

 

This is my code... did I do something wrong? Thanks!

<?php
if (!defined('_PS_VERSION_'))
  exit;
 
class printref extends Module
  {
  public function __construct()
    {
    $this->name = 'printref';
    $this->tab = 'Test';
    $this->version = 1.0;
    $this->author = 'JS';
    $this->need_instance = 0;
 
    parent::__construct();
 
    $this->displayName = $this->l('PrintRef');
    $this->description = $this->l('Prints ref or order id if available. ');
    }
 
  public function install()
    {
    if (parent::install() == false OR !$this->registerHook('rightColumn')
            OR !$this->registerHook('orderConfirmation')
            OR !$this->registerHook('leftColumn'))
        return false;
    return true;
    }
    
  public function hookRightColumn($params)
    {
    global $smarty;
    $this->context->smarty->assign(array(
     'reference' => $params['objOrder']->reference
        ));
    
    return $this->display(__FILE__,'printref.tpl');
    }
 
  public function hookLeftColumn($params)
    {
    return $this->hookRightColumn($params);
    } 
    
  public function hookOrderConfirmation($params)
    {
    return $this->hookRightColumn($params);
    }   
  }
?>
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...