• optional
  • OrderFailureNotification (optional)

    GitHub - magesuite/order-failure-notification

    The module sends emails notifying about order failures. The email contains data that can be useful when debugging the cause of failed order.

     

    Installation

    This module is optional.

    composer require "creativestyle/magesuite-order-failure-notification" ^1.0.0

    Admin settings

    Admin settings can be found under Stores -> Configuration -> MageSuite -> Order Failure Notification

     

    Settings:

    Field

    Options

    Comment

    Field

    Options

    Comment

    Enable notifications for order failure

    Yes/No

    Default value: No

    E-mail address

     

    Multiple e-mail addresses shall be separated with comma

     

    Backend

    To be added

    There is observer vendor/creativestyle/magesuite-order-failure-notification/Observer/QuoteSubmitFailure.php which observers event sales_model_service_quote_submit_failure

     

    This event is triggered while submitting quote.

    If exception appears, addresses will be rollback and after it mentioned event will be triggered.

    vendor/magento/module-quote/Model/QuoteManagement.php

    class QuoteManagement implements CartManagementInterface { public function submit(QuoteEntity $quote, $orderData = []) { ..... return $this->submitQuote($quote, $orderData); } protected function submitQuote(QuoteEntity $quote, $orderData = []) { try { $order = $this->orderManagement->place($order); ..... } catch (\Exception $e) { $this->rollbackAddresses($quote, $order, $e); throw $e; } } private function rollbackAddresses( QuoteEntity $quote, OrderInterface $order, \Exception $e ): void { ..... $this->eventManager->dispatch( 'sales_model_service_quote_submit_failure', [ 'order' => $order, 'quote' => $quote, 'exception' => $e, ] ); ...... } }

     

    vendor/creativestyle/magesuite-order-failure-notification/etc/events.xml

    <event name="sales_model_service_quote_submit_failure"> <observer name="quote_submit_failure_notification" instance="MageSuite\OrderFailureNotification\Observer\QuoteSubmitFailure" shared="true" /> </event>

     

    Observer notify about order failure and there email will be send:

    vendor/creativestyle/magesuite-order-failure-notification/Observer/QuoteSubmitFailure.php

     

    vendor/creativestyle/magesuite-order-failure-notification/Service/Notification.php

    Frontend

    The notification email contains the following data:

    • Order data

    • Quote data

    • Exception message

    • Exception track

    The template is located in: order-failure-notification/view/adminhtml/email/order_failure_notification.html