Order Number: {{ order.orderNumber }}
Customer Name: {{ order.orderCustomer.firstName }} {{ order.orderCustomer.lastName }}
Delivery Status: {{ order.deliveries.first.stateMachineState.translated.name }}
< /code>
Я получаю < /p>
in my shopware6 i get this error [business_events] mail.sent.error ["source" => "core","environment" => "dev","additionalData" => ["exception" => """ Shopware\Core\Framework\Adapter\Twig\Exception\StringTemplateRenderingException: Failed rendering string template using Twig: Variable "order" does not exist in
Но без переменных заказа отправляется почта. /> Защищенная функция Remindermail ($ fname, $ email, $ order, $ context)
{< /p>
$salesChannelConfig = $this->systemConfigService->get('core.defaultSalesChannel');
$salesChannelId = isset($salesChannelConfig['salesChannel'][0]) ? $salesChannelConfig['salesChannel'][0] : null;
$mailTemplate = $this->mailTemplateRepository->search(
(new Criteria(['£££'])), // Search by ID
$context
)->get('£££'); // Get the template by ID
if (!$mailTemplate) {
throw new \RuntimeException('Mail template not found');
}
// dd($order);
// Prepare the data bag
$dataBag = new DataBag();
$recipients = [
$email => $fname,
// Add more recipients as needed
];
$dataBag->set('recipients', $recipients);
$dataBag->set('senderName', 'Your Sender Name');
$dataBag->set('contentHtml', $mailTemplate->getContentHtml());
$dataBag->set('contentPlain', $mailTemplate->getContentPlain());
$dataBag->set('subject', $mailTemplate->getSubject());
$dataBag->set('salesChannelId', $salesChannelId);
// Add any additional data you want to pass to the template
$dataBag->set('data', $order);
// Send the email
$this->mailService->send($dataBag->all(), $context);
}
Привет, я работаю в сценарии, чтобы отправить электронные письма, используя шаблон, созданный на моем Admin Shopware6.[code] Order Number: {{ order.orderNumber }} Customer Name: {{ order.orderCustomer.firstName }} {{ order.orderCustomer.lastName }} Delivery Status: {{ order.deliveries.first.stateMachineState.translated.name }} < /code> Я получаю < /p> in my shopware6 i get this error [business_events] mail.sent.error ["source" => "core","environment" => "dev","additionalData" => ["exception" => """ Shopware\Core\Framework\Adapter\Twig\Exception\StringTemplateRenderingException: Failed rendering string template using Twig: Variable "order" does not exist in [/code] Но без переменных заказа отправляется почта. /> Защищенная функция Remindermail ($ fname, $ email, $ order, $ context) {< /p> [code] $salesChannelConfig = $this->systemConfigService->get('core.defaultSalesChannel'); $salesChannelId = isset($salesChannelConfig['salesChannel'][0]) ? $salesChannelConfig['salesChannel'][0] : null;
$mailTemplate = $this->mailTemplateRepository->search( (new Criteria(['£££'])), // Search by ID $context )->get('£££'); // Get the template by ID
if (!$mailTemplate) { throw new \RuntimeException('Mail template not found'); }
// dd($order); // Prepare the data bag $dataBag = new DataBag(); $recipients = [ $email => $fname, // Add more recipients as needed ]; $dataBag->set('recipients', $recipients); $dataBag->set('senderName', 'Your Sender Name'); $dataBag->set('contentHtml', $mailTemplate->getContentHtml()); $dataBag->set('contentPlain', $mailTemplate->getContentPlain()); $dataBag->set('subject', $mailTemplate->getSubject()); $dataBag->set('salesChannelId', $salesChannelId);
// Add any additional data you want to pass to the template $dataBag->set('data', $order);
// Send the email $this->mailService->send($dataBag->all(), $context); } [/code] Пожалуйста, помогите