Sql 对模板的Prestashop函数查询

Sql 对模板的Prestashop函数查询,sql,variables,prestashop,smarty,Sql,Variables,Prestashop,Smarty,我在prestashop 1.6和classes/Cart.php中进行了测试,可以与模板文件进行通信。 在我所做的返回expect结果的查询中,它在phpmyadmin上工作,在cart.php中工作到tpl文件调用,但只有在我写入客户的id号时,我才想使用变量id customer(使用这种或类似prestashop的工作方式-(int)$id\u customer-)。 任何帮助请 //cart.php的代码 public static function payLater($id_cust

我在prestashop 1.6和classes/Cart.php中进行了测试,可以与模板文件进行通信。 在我所做的返回expect结果的查询中,它在phpmyadmin上工作,在cart.php中工作到tpl文件调用,但只有在我写入客户的id号时,我才想使用变量id customer(使用这种或类似prestashop的工作方式-(int)$id\u customer-)。 任何帮助请

//cart.php的代码

public static function payLater($id_customer)
{
    $sql =  "SELECT ps_customer.pay_later
            FROM ps_customer
            LEFT JOIN ps_cart ON ps_customer.id_customer = ps_cart.id_customer
            ORDER BY ps_cart.id_cart DESC LIMIT 1
            WHERE ps_cart.id_customer =".(int)$id_customer;
    //if i change (int)$id_customer for a real id number like 43 it shows correct info
    $result = Db::getInstance()->getValue($sql);
    return $result;
}
//模板文件的代码

{Cart::payLater(Tools::getvalue('pay_later'))}
tpl文件中的{Cart::payLater($customer.id)}。我也编辑了你的函数。请检查下面的空客户id

public static function payLater($id_customer)
{
   if((int)$id_customer == 0){ return; } // check if customer id is blank
    $sql =  "SELECT ps_customer.pay_later
            FROM ps_customer
            LEFT JOIN ps_cart ON ps_customer.id_customer = ps_cart.id_customer
            ORDER BY ps_cart.id_cart DESC LIMIT 1
            WHERE ps_cart.id_customer =".(int)$id_customer;
    //if i change (int)$id_customer for a real id number like 43 it shows correct info
    $result = Db::getInstance()->getValue($sql);
    return $result;
}

您是否在tpl文件中打印了$customer.id?你得到了什么?