2016-07-20 3 views
2

На моем classes/PaymentModule.php Я объявил '{message}' => $customer_message (между другими варами), но все же мои клиенты видят Wiadomość: {message} в письмах, которые они получили.Невозможно добавить переменную {message} к шаблону почты order_conf

Что я не так? Может быть, объявить {message} var в PaymentModule.php недостаточно?

UDPATE:

это стандартный код PaymentModule.php в Prestashop 1.6.2.1 с добавлением {сообщение} переменной:

$customer_message = $order->getFirstMessage(); 
$data = array(
      '{firstname}' => $this->context->customer->firstname, 
      '{lastname}' => $this->context->customer->lastname, 
      '{email}' => $this->context->customer->email, 
      '{delivery_block_txt}' => $this->_getFormatedAddress($delivery, "\n"), 
      '{invoice_block_txt}' => $this->_getFormatedAddress($invoice, "\n"), 
      '{delivery_block_html}' => $this->_getFormatedAddress($delivery, '<br />', array(
       'firstname' => '<span style="font-weight:bold;">%s</span>', 
       'lastname' => '<span style="font-weight:bold;">%s</span>' 
      )), 
      '{invoice_block_html}' => $this->_getFormatedAddress($invoice, '<br />', array(
        'firstname' => '<span style="font-weight:bold;">%s</span>', 
        'lastname' => '<span style="font-weight:bold;">%s</span>' 
      )), 
      '{delivery_company}' => $delivery->company, 
      '{delivery_firstname}' => $delivery->firstname, 
      '{delivery_lastname}' => $delivery->lastname, 
      '{delivery_address1}' => $delivery->address1, 
      '{delivery_address2}' => $delivery->address2, 
      '{delivery_city}' => $delivery->city, 
      '{delivery_postal_code}' => $delivery->postcode, 
      '{delivery_country}' => $delivery->country, 
      '{delivery_state}' => $delivery->id_state ? $delivery_state->name : '', 
      '{delivery_phone}' => ($delivery->phone) ? $delivery->phone : $delivery->phone_mobile, 
      '{delivery_other}' => $delivery->other, 
      '{invoice_company}' => $invoice->company, 
      '{invoice_vat_number}' => $invoice->vat_number, 
      '{invoice_firstname}' => $invoice->firstname, 
      '{invoice_lastname}' => $invoice->lastname, 
      '{invoice_address2}' => $invoice->address2, 
      '{invoice_address1}' => $invoice->address1, 
      '{invoice_city}' => $invoice->city, 
      '{invoice_postal_code}' => $invoice->postcode, 
      '{invoice_country}' => $invoice->country, 
      '{invoice_state}' => $invoice->id_state ? $invoice_state->name : '', 
      '{invoice_phone}' => ($invoice->phone) ? $invoice->phone : $invoice->phone_mobile, 
      '{invoice_other}' => $invoice->other, 
      '{order_name}' => $order->getUniqReference(), 
      '{date}' => Tools::displayDate(date('Y-m-d H:i:s'), null, 1), 
      '{carrier}' => ($virtual_product || !isset($carrier->name)) ? Tools::displayError('No carrier') : $carrier->name, 
      '{payment}' => Tools::substr($order->payment, 0, 32), 
      '{products}' => $product_list_html, 
      '{products_txt}' => $product_list_txt, 
      '{discounts}' => $cart_rules_list_html, 
      '{discounts_txt}' => $cart_rules_list_txt, 
      '{total_paid}' => Tools::displayPrice($order->total_paid, $this->context->currency, false), 
      '{total_products}' => Tools::displayPrice(Product::getTaxCalculationMethod() == PS_TAX_EXC ? $order->total_products : $order->total_products_wt, $this->context->currency, false), 
      '{total_discounts}' => Tools::displayPrice($order->total_discounts, $this->context->currency, false), 
      '{total_shipping}' => Tools::displayPrice($order->total_shipping, $this->context->currency, false), 
      '{total_wrapping}' => Tools::displayPrice($order->total_wrapping, $this->context->currency, false), 
      '{message}' => $customer_message, 
      '{total_tax_paid}' => Tools::displayPrice(($order->total_products_wt - $order->total_products) + ($order->total_shipping_tax_incl - $order->total_shipping_tax_excl), $this->context->currency, false)); 

В order_conf.html:

... 
Wiadomość: {message} 
.... 
+0

Можете ли вы показать код? Код, в котором вы объявляете свою гибкую переменную и шаблон, который использует эту переменную. –

+0

Я не вижу в вашем массиве '$ data' сообщение '{message}'. –

+0

Извините, я скопировал чистый код с другим магазином ... Добавлено – user3041764

ответ

0

НУ должны используйте ниже, если вы еще не используете его. Пример:

$id_lang = (int)$this->context->language->id; 
$heading = Mail::l('Message Received', (int)$id_lang); 
Mail::Send(
       (int)$id_lang, 
       'order_conf', 
       $heading, 
       $data, 
       $this->context->customer->email, 
       null, 
       null, 
       $this->context->shop->name, 
       null, 
       null, 
       _PS_MODULE_DIR_.'mymodule/mail/', 
       false, 
       1 
       ); 

шаблон почты должен быть расположен в 'mymodule/mail/en/order_conf.html' делают языки каталоги в соответствии с вашими языками как/еп,/пт,/нл

0

С Prestashop 1.7, я протестировал с

'{message}' => 'hello', 

И он показывает в электронной почте: привет

вы уверены, что у вас есть что-то в $customer_message?

Это может быть сложнее с некоторыми переменными. Взгляните на $product_list_html

Вы увидите, что это массив и есть:

$product_list_html = $this->getEmailTemplateContent('order_conf_product_list.tpl', Mail::TYPE_HTML, $product_var_tpl_list); 

Он использует другой шаблон для создания списка продукции (order_conf_product_list.tpl)