Php Prestashop可以访问自定义模块中的购物车变量

Php Prestashop可以访问自定义模块中的购物车变量,php,prestashop,prestashop-1.6,Php,Prestashop,Prestashop 1.6,在prestashop中,我希望在我的付款模块中获得确切的付款详细信息步骤数据。所以我只是从order-payment.tpl复制了代码,并在我的支付执行smarty文件中使用了它。它显示了几个错误。因此,我只需遍历代码,从购物车中获取这些值,并将其从我的支付控制器分配到smarty模板。一切正常,但我仍然得到一个错误命名为 Undefined index: gift_products . 当我在Cart.php中检查代码时,我得到了如下结果 $gift_products = array();

在prestashop中,我希望在我的付款模块中获得确切的付款详细信息步骤数据。所以我只是从order-payment.tpl复制了代码,并在我的支付执行smarty文件中使用了它。它显示了几个错误。因此,我只需遍历代码,从购物车中获取这些值,并将其从我的支付控制器分配到smarty模板。一切正常,但我仍然得到一个错误命名为

Undefined index: gift_products .
当我在Cart.php中检查代码时,我得到了如下结果

$gift_products = array();
$gift_product = $product;
$gift_product['cart_quantity'] = 1;
$gift_product['price'] = 0;
$gift_product['price_wt'] = 0;
$gift_product['total_wt'] = 0;
$gift_product['total'] = 0;
$gift_product['gift'] = true;
$gift_products[] = $gift_product;

I tried to assign the value of gift_products to the smarty like this

public function initContent()
{
    parent::initContent();

    $cart = $this->context->cart;
    $this->context->smarty->assign(array(
        'gift_products' => $cart->gift_products,
    ));

    $this->setTemplate('payment_execution.tpl');
}
但它根本不起作用。有人能告诉我如何在我的模块中使用cart的变量/数组吗?任何帮助和建议都是非常值得的。谢谢。

使用

$summary = $this->context->cart->getSummaryDetails();
$gift_products = $summary['gift_products'];