When Order placed consume a web service

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 Jahre weitere
Hi everybody, I want to consume a web service (by sending an order number as a parameter) when the order is placed. what can I do this. if possible Could you send me a complete sample ?

Thanks
7 Jahre weitere
I'm using nopcommerce 3.8
7 Jahre weitere
bulentgokdas wrote:
Hi everybody, I want to consume a web service (by sending an order number as a parameter) when the order is placed. what can I do this. if possible Could you send me a complete sample ?

Thanks


When the order submitted a event fired and you can catch the event from your plugin.



public class OrderEventConsumer : IConsumer<OrderPlacedEvent>
    {
        private readonly IPluginFinder _pluginFinder;
        private readonly IOrderService _orderService;
        private readonly IStoreContext _storeContext;
        public OrderEventConsumer(
            IPluginFinder pluginFinder,
            IOrderService orderService,
            IStoreContext storeContext)
        {
            this._pluginFinder = pluginFinder;
            this._orderService = orderService;
            this._storeContext = storeContext;
        }

        /// <summary>
        /// Handles the event.
        /// </summary>
        /// <param name="eventMessage">The event message.</param>
        ///    [HubMethodName("liveNotification")]
        ///    
        public void HandleEvent(OrderPlacedEvent eventMessage)
        {
            var order = eventMessage.Order;
            var products = order.OrderItems;
  
        }
    }
7 Jahre weitere
sina.islam wrote:
When the order submitted a event fired and you can catch the event from your plugin.



Hi, I'm new at nopcommerce
Should I write a new plugin or use an existing plugin?

If I have to use the existing one, which one?

Thanks
7 Jahre weitere
bulentgokdas wrote:

Should I write a new plugin or use an existing plugin?

If I have to use the existing one, which one?

Thanks


First thing, Plugins are a set of components adding specific capabilities to a nopCommerce store. So, it would be more preferable(Best practices) to create a new plugin. And do not make any changes to the existing plugins.
7 Jahre weitere
Thanks, I will try write a new plugin
7 Jahre weitere
Look at the SMS plugin; it is example of handling Order Placed event
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.