Show $params array('{item}' =>…)

2019-08-15 22:19发布

问题:

Need some help. Have this code in PaymentModule.php in Prestashop:

$params = array(
    '{voucher_amount}' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false),
    '{voucher_num}' => $voucher->code,
    '{firstname}' => $this->context->customer->firstname,
    '{lastname}' => $this->context->customer->lastname,
    '{id_order}' => $order->reference,
    '{order_name}' => $order->getUniqReference()
);

I use $params['firstname'] for showing customer firstname and get nothing. I insert $params['firstname'] in /modules/bankwire/bankwire.php

Please tell me where I make a mistake?

Thanks

回答1:

In your array you have a {firstname} key, but no firstname key.

If you want to get value, you should use: $params['{firstname}']



回答2:

Try

$params = array(
    'voucher_amount' => Tools::displayPrice($voucher->reduction_amount, $this->context->currency, false),
    'voucher_num' => $voucher->code,
    'firstname' => $this->context->customer->firstname,
    'lastname' => $this->context->customer->lastname,
    'id_order' => $order->reference,
    'order_name' => $order->getUniqReference()
);

or in the case that volkerk is right, try

$params['{firstname}'] 


回答3:

there is variables for email template, it's just assoc array, for access use

$params['{voucher_amount}']