Jump to content

Module not displaying in Prestashop 1.7.7.3


dguna

Recommended Posts

I implemented a module in Prestashop to add a field in Orders page. Once filled, this field will appear in the bill of the purchase. My module worked well until 1.7.7.3 came... Now there is no display.

For now I replaced my module code with some sample code just to test the display but it doesn't work neither.. Could someone explain if there is an obvious error or advice a tutorial ?

<?php
if (!defined('_PS_VERSION_'))
  exit;

use PrestaShop\PrestaShop\Core\Payment\PaymentOption;
  
class PurchaseOrder extends PaymentModule
{
    public function install()
    {

        if ( parent::install()
            && $this->registerHook('displayAdminOrder')
            && $this->registerHook('displayAdminOrderLeft')
            && $this->registerHook('displayAdminOrderRight')
            && $this->registerHook('dsplayAdminOrderTabOrder')
            && $this->registerHook('displayAdminOrderContentShip')
            && $this->registerHook('displayAdminOrderContentOrder')
                       

        ) {
            return true;
        }

        $this->uninstall();
        return false;
    }

    /**
     * displayAdminOrderContentShip
     */
    public function hookDisplayAdminOrderContentShip($param)
    {
        return '<b>hookDisplayAdminOrderContentShip</b>';
    }

    /**
     * @hook displayAdminOrderLeft
     */
    public function hookDisplayAdminOrderLeft($param)
    {
        return '<b>hookDisplayAdminOrderLeft</b>';
    }

    /**
     * displayAdminOrderRight
     */
    public function hookDisplayAdminOrderRight($param)
    {
        return '<b>hookDisplayAdminOrderRight</b>';
    }

    /**
     * @hook displayAdminOrder
     */
    public function hookDisplayAdminOrder($param)
    {
        return '<b>hookDisplayAdminOrder</b>';
    }

    /**
     * displayAdminOrderContentOrder
     */
    public function hookDisplayAdminOrderContentOrder($param)
    {
        return '<b>hookDisplayAdminOrderContentOrder</b>';
    }

 

2021-04-20_11h43_02.png

Link to comment
Share on other sites

Hello,

why you set in every display function this <b></b> ?

As i know html doesn´t work in PHP....Your function can´t be called this way

return '<b>hookDisplayAdminOrderContentShip</b>';

return '<b>hookDisplayAdminOrderLeft</b>';

return '<b>hookDisplayAdminOrderRight</b>';

return '<b>hookDisplayAdminOrder</b>';

return '<b>hookDisplayAdminOrderContentOrder</b>';

 

better try

return 'hookDisplayAdminOrderContentOrder';

so the php function is callable in php

Edited by Magicalname
typo (see edit history)
Link to comment
Share on other sites

9 hours ago, Magicalname said:

Hello,

why you set in every display function this <b></b> ?

As i know html doesn´t work in PHP....Your function can´t be called this way

return '<b>hookDisplayAdminOrderContentShip</b>';

return '<b>hookDisplayAdminOrderLeft</b>';

return '<b>hookDisplayAdminOrderRight</b>';

return '<b>hookDisplayAdminOrder</b>';

return '<b>hookDisplayAdminOrderContentOrder</b>';

 

better try

return 'hookDisplayAdminOrderContentOrder';

so the php function is callable in php

Hi, 

Thanks for the response ! 

But not sure to understand your correction. I put return everywhere just to see where the hooks are displaying. This is just a test and I want to see where are the displays. 

The problem is that in my screenshot, there is only only display and I don't understand why, is it linked to a .tpl file ? 

I'd like to have an input field which (when filled) will write the content in the PDF invoice. 

Thanks 

Link to comment
Share on other sites

  • 2 weeks later...

Still have the same problem, I tried to display my purchase order module but nothing. Here is the hook: 

	public function hookDisplayAdminOrder($params)
	{
		$id_order = (int)($_REQUEST['id_order']);
		if(isset($_REQUEST['purchaseorderReference']))
		{
			$po_number = $_REQUEST['po_number'];
			$sql = 'UPDATE '._DB_PREFIX_.'orders SET po_number="'.$po_number.'" WHERE id_order='.$id_order;
			Db::getInstance()->execute($sql);
		}
	
		// Récupération de po_number
		$sql='SELECT po_number FROM '._DB_PREFIX_."orders WHERE id_order = '".$id_order."' ";
		$results = Db::getInstance()->getRow($sql);
		
		$sql='SELECT payment FROM '._DB_PREFIX_."orders WHERE id_order = '".$id_order."' ";
		$paymentmode = Db::getInstance()->getRow($sql);
		
		$this->smarty->assign(array(
			'po_number' 	=> $results['po_number'],
			'payment_mode'	=> $paymentmode['payment'],
		));
		
		//return '<b>PURCHASE ORDER ZONE</b>';
		return $this->display(__FILE__, 'admin_purchaseorder.tpl');
	}

And the .tpl: 

{if $payment_mode}
<div class="row">
<div class="panel panel-sm col-lg-12">
    <div class="panel-heading">
        <i class="icon-credit-card"></i>
        {l s='Purchase Order' mod='purchaseorder'}
    </div>
    <form method="post" action="" class="form-horizontal" id="purchaseorder_form">
		<div class="form-group">
        	<label class="control-label col-lg-5">{l s='Purchase order number' mod='purchaseorder'}</label>
            <div class="col-lg-4" style="margin-top:6px"><strong>{$po_number}</strong></div>
        </div>
        <div class="form-group">
        	<label class="control-label col-lg-5">{l s='Modify the purchase order' mod='purchaseorder'}</label>
            <div class="col-lg-6">
                <input type="text" style="width:266px" id="po_number" name="po_number"/>
                <input type="hidden" name="purchaseorderReference" value="1"/>
            </div>
        </div>
        <div class="form-group">
             <div class="col-lg-11">
                <a class="btn btn-default pull-right" id="submitCustomerNote" href="javascript:void(0)" onclick="updatePurchaseorder()">
                    <i class="icon-save"></i>
                    {l s="Save" mod="purchaseorder"}
                </a>
            </div>
        </div>
    </form>
</div>
</div>
<script>
function updatePurchaseorder()
{
	$('#purchaseorder_form').submit();
}
</script>
{/if}

I repeat the problem, this module should be display in Order menu at the bottom of the page but for now nothing. And it happened only with the migration to 1.7.7.3, beofre it was working.

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