ShippmentSent Event

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
Hi,
I want to implement the SMS Send in my SMS plugin in way to send a message to the customer when we confirm the shippment.
I am looking for the event ("ShippmentSent") and also some suggestion to a right development...

Thanks
11 years ago
You should be able to consume order update event (inherit IConsumer<EntityUpdated<Order>>), and check  order.OrderStatus and/or order.ShippingStatus
11 years ago
Hi,
I try and update all you about the result..

Thanks
11 years ago
I tried to create a new class as follows:

public class OrderUpdateEventConsumer : IConsumer<EntityUpdated<Order>>

but <EntityUpdated<Order>> is not recognized.

Better result with public class OrderUpdateEventConsumer : IConsumer<OrderUpdateEvent> and definition of a new event :

public class OrderUpdateEvent
    {
        private readonly Order _order;

        public OrderUpdateEvent(Order order)
        {
            this._order = order;
        }

        public Order Order
        {
            get { return _order; }
        }
    }

but in this case the class OrderUpdateEventConsumer (HandleEvent) is not able to recognize the object Order ...
I have also published the event:

public static void PublishOrderUpdate(this IEventPublisher eventPublisher, Order order)
        {
            eventPublisher.Publish(new OrderUpdateEvent(order));
        }


Any suggestion? I think that use OrderUpdate is the right way but I miss something ...

Thanks
11 years ago
It is solve... I missed the definition in the  EventPublisherExtensions

         /// <summary>
        /// Publishes the order update event.
        /// </summary>
        /// <param name="eventPublisher">The event publisher.</param>
        /// <param name="order">The order.</param>
        public static void PublishOrderUpdate(this IEventPublisher eventPublisher, Order order)
        {
            eventPublisher.Publish(new OrderUpdateEvent(order));
        }


Now this event working perfectly!!

Thanks all and I hope it should be usefull to somebody
11 years ago
I don't think it's necessary to publish an an event like that.  I think you were just missing inheriting from the BasePlugin, and maybe some "using"s

using Nop.Core.Domain.Orders;
using Nop.Core.Domain.Payments;
using Nop.Core.Events;
using Nop.Core.Plugins;
using Nop.Services.Orders;
...

namespace Nop.Plugin.MyCompany.MyPlugin
{

    public class MyPlugin : BasePlugin, IConsumer<EntityUpdated<Order>>
    {
       ...

        public void HandleEvent(EntityUpdated<Order> eventMessage)
        {
11 years ago
New York wrote:
I don't think it's necessary to publish an an event like that.  I think you were just missing inheriting from the BasePlugin, and maybe some "using"s

using Nop.Core.Domain.Orders;
using Nop.Core.Domain.Payments;
using Nop.Core.Events;
using Nop.Core.Plugins;
using Nop.Services.Orders;
...

namespace Nop.Plugin.MyCompany.MyPlugin
{

    public class MyPlugin : BasePlugin, IConsumer<EntityUpdated<Order>>
    {
       ...

        public void HandleEvent(EntityUpdated<Order> eventMessage)
        {



Thanks a lot.
It helps me a lot...
11 years ago
New York wrote:
I don't think it's necessary to publish an an event like that.  I think you were just missing inheriting from the BasePlugin, and maybe some "using"s

using Nop.Core.Domain.Orders;
using Nop.Core.Domain.Payments;
using Nop.Core.Events;
using Nop.Core.Plugins;
using Nop.Services.Orders;
...

namespace Nop.Plugin.MyCompany.MyPlugin
{

    public class MyPlugin : BasePlugin, IConsumer<EntityUpdated<Order>>
    {
       ...

        public void HandleEvent(EntityUpdated<Order> eventMessage)
        {


I'm having one problem.

When I set mark as shipment on order update, then it sends so many sms.
I investigated this problem.

This is because when sending sms , I also update order note for the same to notify admin.

And again order entity updates ...sending sms...it begins one type of loop and never stop. means it goes in infinite loop.

I don't know how to solve it?
How to get actual event that order shipment?
11 years ago
This is what I've done in the past.  I think it's safe, as each 'session' should be creating its own instance of the class


public class MyPlugin : BasePlugin, IConsumer<EntityUpdated<Order>>
{
...
    private bool updatesMade = false;
...

    public void HandleEvent(EntityUpdated<Order> eventMessage)
    {
        if (updatesMade) return; // because we update the order below, we get called again for event
...
11 years ago
New York wrote:
This is what I've done in the past.  I think it's safe, as each 'session' should be creating its own instance of the class


public class MyPlugin : BasePlugin, IConsumer<EntityUpdated<Order>>
{
...
    private bool updatesMade = false;
...

    public void HandleEvent(EntityUpdated<Order> eventMessage)
    {
        if (updatesMade) return; // because we update the order below, we get called again for event
...


Thanks for your reply.
But I'm not totally clear.When will updatesMade's true? Can you elaborate it ?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.