Can a custom plugin alter HandleEventAsync to manage PlaceOrderAsync errors, ensuring false for cancellations, without affecting system functionality

4 months ago
I aim to enhance the functionality of the
HandleEventAsync(OrderPlacedEvent eventMessage) 
method by incorporating custom code capable of returning specific errors. In cases where an error is encountered, I desire that the
PlaceOrderAsync
method promptly returns the error, preventing the continuation of the process. Currently, there is an inconsistency in the behavior, specifically when an order is cancelled; the expected result is false instead of true, as seen in the following code snippet:

if (result.Success)
    return result;

I am exploring options to modify this behavior through the integration of a custom plugin. Ideally, I aim to maintain the vanilla functionality of the system while allowing the mentioned check to be handled exclusively by the plugin. Is there a method or configuration that enables me to achieve this customization?
4 months ago
OrderPlacedEvent is used to notify handlers that the order has already been placed, rather than being placed right now. To completely control the order placing process from the plugin you should override IOrderProcessingService.PlaceOrderAsync() method.
4 months ago
RomanovM wrote:
OrderPlacedEvent is used to notify handlers that the order has already been placed, rather than being placed right now. To completely control the order placing process from the plugin you should override IOrderProcessingService.PlaceOrderAsync() method.


Considering the provided response, could you provide an example or share the best practices for implementing the override? So that i would not write all the not necessary code just the one that i need
4 months ago
There are lots of posts in the form about Overrides
You could look at the Nop.Plugin.Misc.Sendinblue pluign
It overerides the SendEmailAsync routine in the file
Nop.Plugin.Misc.Sendinblue\Services\SendinblueEmailSender.cs
Its the same idea you just need to overrde a different function
4 months ago
Yidna wrote:
There are lots of posts in the form about Overrides
You could look at the Nop.Plugin.Misc.Sendinblue pluign
It overerides the SendEmailAsync routine in the file
Nop.Plugin.Misc.Sendinblue\Services\SendinblueEmailSender.cs
Its the same idea you just need to overrde a different function


Thank you for your assistance; the issue has been resolved. I utilized the forum topic to ensure a seamless experience and avoid encountering any errors.
Similar Topic