Suggestion : Change in the PlaceOrder Function in the Order Processing Service.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
8 anos atrás
//raise event  
_eventPublisher.Publish(new OrderPlacedEvent(order));

raise event  line should be before   #region Notifications & notes


Reason : if I consume OrderPlacedEvent in my plugin and want to add new order token from the Plugin, which can be used in the Email Template.
I can not do it. Because Emails are send before OrderPlacedEvent.
8 anos atrás
Could you please clarify how exactly you want to add new tokens in handler of this event?
8 anos atrás
yes i think you can move it before Notification Notes.

and from plugin you can override the Token filling method of TokenProviderService to call and use plugin once to fill the tokens.

but then it will always call the plugins one not the core service for fill particular tokens.
8 anos atrás
This event should not be moved before notifications. It's better to add one more event for such purposes.

But why don't you want to create one more service class derived from TokenProviderService (e.g. CustomTokenProviderService). Then you can override this certain token filling method and add your custom tokens. And then you can register and use it instead of the default TokenProviderService. So CustomTokenProviderService will always be used instead of the TokenProviderService. Not just before order placed event.
8 anos atrás
a.m. wrote:
This event should not be moved before notifications. It's better to add one more event for such purposes.

But why don't you want to create one more service class derived from TokenProviderService (e.g. CustomTokenProviderService). Then you can override this certain token filling method and add your custom tokens. And then you can register and use it instead of the default TokenProviderService. So CustomTokenProviderService will always be used instead of the TokenProviderService. Not just before order placed event.


I agree for adding new event will be good aproach.
8 anos atrás
Hi,

My Requirement is that to Create a New Table "CustomOrderInvoiceNumber" using Plugin
Table will be like
Id  OrderId  OrderInvoiceNumber

Or

OrderId   OrderInvoiceNumber


When a New Order will be placed, an OrderInvoiceNumber will be created and Data  will be save in the CustomOrderInvoiceNumber

and in Email Template I can use new Tokens  like  CustomOrderInvoiceNumber.OrderInvoiceNumber

Thanks
8 anos atrás
In this case you can follow my suggestion above (CustomTokenProviderService). THis new event is not required
8 anos atrás
Hi,

I am agree that I can use new Tokens using the CustomTokenProviderService.

Problem :
At what point I can  Create OrderInvoiceNumber  and store in the My New Table. ?

1. By using New Event , I can create this OrderInvoiceNumber.
2. By Override PlaceOrder function .

I dont think to Override PlaceOrder is a good option, so If OrderPlaceEvent will be place before the Notification and Emails,
I can consume it.
or

If any new Event will be raised , I can consume New Event.

Please Provide your Suggestion. Thanks in advice.
8 anos atrás
If I understand correctly you want to generate an invoice number when the order is placed and add the invoice number in the order placed email?

If you want to do this with minimal overrides you could do as followed:

- disable the default order placed template and add an extra mail template ( i.e. OrderPlacedWithInvoice )
This way the default nopCommerce orderplaced email won't be sent out.

- consume the orderplaced event, add your custom invoice and send the mail using your custom OrderPlacedWithInvoice template

- use the CustomTokenProviderService to insert the invoice number in the mail using your own custom message token.
8 anos atrás
vikas.chabra wrote:

Problem :
At what point I can  Create OrderInvoiceNumber  and store in the My New Table. ?

1. By using New Event , I can create this OrderInvoiceNumber.
2. By Override PlaceOrder function .

I dont think to Override PlaceOrder is a good option, so If OrderPlaceEvent will be place before the Notification and Emails,
I can consume it.


yes for inserting record in to OrderInvoiceNumber  you need to create new event that will called before notification & emails.

so that will insert record and from CustomerTokenProvider you can fill your custom tokens.

i think Override whole PlaceOrder is not a good approch
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.