如何在模板中显示来自prestashop模块的值

时间:2018-07-25 20:48:30

标签: php templates module prestashop

我如何在div的prestashop模板页面中显示变量,因为它现在位于页面顶部。

public function hookDisplayCustomerAccount()
{
   global $smarty;
   $userid = $this->context->customer->id;
   $sql = "SELECT SUM(total_paid) FROM ps_orders  WHERE id_customer = '$userid' AND current_state = '1' ";
   $result = Db::getInstance()->ExecuteS($sql);
   $custdata=array();
   $sum = 0;
   foreach ($result as $row)
   {
       /*  $custdata[] = array(
           "id_order" => round( $row['SUM(total_paid)'] ,2),
       );*/
       echo round( $row['SUM(total_paid)'] ,2);
    }
    //$this->context->smarty->assign("custdata", $custdata);
    }
}

1 个答案:

答案 0 :(得分:0)

尝试像这样在模板页面中的所需位置调用该钩子

{hook h='displayCustomerAccount' mod='yourmodulename'}

PS:如果仅在displayCustomerAccount上挂接了此模块,则可以排除'mod'。

干杯:)