Send entity, reference and amount by email with order confirmation.

Created on 27 April 2023, over 1 year ago
Updated 6 November 2023, about 1 year ago

Hello guys.
It is possible for MB payment (entity, reference and amount) to be sent by email together with the order confirmation? This details only appears once time, and it is at the end of the ordering process.
If the customer is not paying attention, he loses this information and does not process the payment.

Abraço

💬 Support request
Status

Fixed

Version

2.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @uaparac
  • Status changed to Fixed about 1 year ago
  • 🇵🇹Portugal introfini

    Hi,

    The related Drupal Commerce issue: 📌 Show payment instructions in the order receipt Needs work

    You need to create a Twig variable that contains payment instructions. This variable can subsequently be incorporated into your email template.

    Below is an example of how you might define this variable within Twig. Please note that the exact implementation may vary depending on the method you utilize to dispatch emails:

    function bloom_custom_preprocess_easy_email_commerce_order_payment_method_html(&$variables)
    {
        /** @var Drupal\commerce_order\Entity\OrderInterface $order */
        $order = $variables["commerce_order"];
        if ($order->get('payment_gateway')->isEmpty()) {
            return;
        }
    
        /** @var \Drupal\commerce_payment\Entity\PaymentGatewayInterface $payment_gateway */
        $payment_gateway = $order->get('payment_gateway')->entity;
        /** @var \Drupal\commerce_payment\Plugin\Commerce\PaymentGateway\HasPaymentInstructionsInterface $payment_gateway_plugin */
        $payment_gateway_plugin = $payment_gateway->getPlugin();
        if ($payment_gateway_plugin instanceof HasPaymentInstructionsInterface) {
            $payment_storage = \Drupal::entityTypeManager()
                ->getStorage('commerce_payment');
            $payments = $payment_storage->loadMultipleByOrder($order);
            $payments = array_filter($payments, function ($payment) use ($payment_gateway) {
                return $payment->getPaymentGatewayId() == $payment_gateway->id();
            });
            $payment = reset($payments);
            if ($payment) {
                $variables['payment_instructions'] = $payment_gateway_plugin->buildPaymentInstructions($payment);
            }
        }
    
    }

    Once you have defined the variable, you can include it in your email template using {{ payment_instructions }}

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024