【发布时间】:2020-09-17 11:20:35
【问题描述】:
我在 prestashop 1.6 和 classes/Cart.php 中测试过,我可以与模板文件进行通信。 在我为返回预期结果所做的查询中,在 phpmyadmin 上工作,并且在 cart.php 中工作到 tpl 文件调用,但只有当我写客户的 id 号,并且我想使用变量 id customer 时(具有 THIS 或类似 prestashop 工作方式的东西 - (int)$id_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'))}
【问题讨论】:
标签: sql variables prestashop smarty