簡體   English   中英

Prestashop可以訪問自定義模塊中的購物車變量

[英]Prestashop get access to cart variables in the custom module

在prestashop中,我想在我的付款模塊中獲取確切的付款明細步驟數據。 因此,我只復制了order-payment.tpl中的代碼,並將其用於我的付款執行智能文件中。 它顯示了幾個錯誤。 因此,我只需遍歷代碼並從購物車中獲取這些值,然后將其從我的付款控制器分配到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');
}

但是它根本不起作用。 有人可以告訴我如何在模塊中使用購物車的變量/數組嗎? 任何幫助和建議都是非常可取的。 謝謝。

采用

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM