Closed axe1987 closed 3 years ago
Hello,
thank you very much for your message.
I honestly don't understand why you want to include the invoice number in the confirmation email. From my point of view this is neither useful for the customers nor technically feasible. Because after the order is completed, the confirmation email is sent. This process is separate from the invoice creation process, which happens later.
With kind regards Jan
Hello,
@janteuber i think he was talking about the TXID, not the Invoice Number.
I'm facing same issue and would like to show the TXID in prepayment order confirmation, as the customer should use it as bank transfer reference. But the customFields seem to be not available yet on CheckoutOrderPlacedEvent
.
Any ideas how to solve it?
I have the same problem. At the time of sending that confirmation email the customFields are still empty/missing. How can I solve this?
Hello @felixgoldstein @vardumper , We already write the TXid on the order confirmation.
Hello @janteuber
i assume you are refering to the finish page.
I try to show this TXID in the order_confirmation_mail
, which is triggered in the FlowBuilder using the OrderPlaced
Event.
Payones Custom Fields are not available here.
Hello @felixgoldstein
I got that mail yesterday:
Okay, great, so it somehow works :) How is it applied to the mail template? Its not in the sourcecode of this extension.
This information is placed in the emails through the $_infoBlockType
property of each payment model.
https://github.com/PAYONE-GmbH/magento-2/blob/master/Model/Methods/Creditcard.php#L50
There are a couple of different "templates" for these for different payment types. https://github.com/PAYONE-GmbH/magento-2/tree/master/Block/Info
The only payment method where no transaction-id or clearing reference is shown should be cash on delivery since its not needed there.
If this info is not shown in these emails, I would suppose that the email template has been changed and the infoBlock was not integrated in the changed template.
Hi @FatchipRobert your links refer to magento-2 plugin.
Uuh sorry @felixgoldstein,
That was my mistake. I have mixed up the shop systems. @FatchipRobert is our M2 expert. I will clarify the issue again for SW 6.
Hello @felixgoldstein ,
It seems that it is not possible to include the reference in the confirmation mail, at least if we use the "Order placed" flow for the mail as usual. Here (https://developer.shopware.com/docs/concepts/commerce/checkout-concept/payments) the exact process of a payment is explained and the payment is always finally executed after the order has been "placed". This means that the event "Order placed" is triggered before the payment or the requests to Payone take place and therefore the mail is also sent beforehand, where the reference is not yet stored with the order.
@janteuber Yep, thats the problem.
I now solved it by creating my own OrderFinalized
Event and made the FlowBuilder aware of it to send out the confirmation mail containing payment instructions. In case of payone and prepayment/invoice. the txid is essential to show in the confirmation mail. The OrderPlaced
is kind of useless here.
@felixgoldstein any more information on how you solved this? To get an OrderFinalized
event one needs to create a plugin? Very confusing that this does not work out of the box and the integration guide does not provide any meaningful solution, yet it encourages to add the txid to the mail template 🤷🏽
@niclashoyer i have create a custom flow event and trigger (FinishEvent) and added it to the flow builder: https://developer.shopware.com/docs/guides/plugins/plugins/framework/flow/add-flow-builder-trigger#create-a-new-trigger-event
then i created a event subscriber to CheckoutFinishPageLoadedEvent
to make sure the mails will be sent only once, i flag it in the orders custom fields
public static function getSubscribedEvents(): array
{
return [
CheckoutFinishPageLoadedEvent::class => 'onCheckoutFinish',
];
}
public function onCheckoutFinish(CheckoutFinishPageLoadedEvent $event): void
{
$salesChannelContext = $event->getSalesChannelContext();
$context = $salesChannelContext->getContext();
$order = $event->getPage()->getOrder();
$customFields = $order->getCustomFields();
if (!isset($customFields['confirmation_mail_sent']) || !$customFields['confirmation_mail_sent']) {
$criteria = new Criteria([$order->getId()]);
$criteria
->addAssociation('orderCustomer.customer')
->addAssociation('orderCustomer.salutation')
->addAssociation('deliveries.shippingMethod')
->addAssociation('deliveries.shippingOrderAddress.country')
->addAssociation('transactions.paymentMethod')
->addAssociation('lineItems.cover')
->addAssociation('currency')
->addAssociation('addresses.country')
->getAssociation('transactions')->addSorting(new FieldSorting('createdAt'));
/** @var OrderEntity|null $orderEntity */
$orderEntity = $this->orderRepository->search($criteria, $context)->first();
$orderFinishEvent = new FinishEvent(
$context,
$orderEntity,
$salesChannelContext->getSalesChannelId()
);
$this->eventDispatcher->dispatch($orderFinishEvent);
$this->orderRepository->upsert([[
'id' => $order->getId(),
'customFields' => [ 'confirmation_mail_sent' => true, 'confirmation_mail_sent_at' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT)]
]], $context);
}
}
Hi.
I want to add the invoice reference to the order confirmation template.
But I keep getting null for the customFields.
Therefore I checked the database entry and I could see that the transaction gets updated, only seconds (milliseconds) after it's creation.
Therefore I have the following assumtion: The customFields for the order_transaction gets added a few seconds after the orderConfirmation Email gets processed. And therefore I get a null on the customFields.
Is that correct?
How can I add the Reference number to the order confirmation email????
Greets axe