How to return error from a plugin

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
8 年 前
Hi, I'm coding a plugin that implements IConsumer EntityInserted<ShoppingCartItem>

When a product is inserted in the cart I check if the current avaiability is bigger or equal to the requested quantity.


public void HandleEvent(EntityInserted<ShoppingCartItem> eventMessage)
    {
         int quantity = eventMessage.Entity.Quantity;
         int avaiableQuantity= _REQUEST_TO_WEB_SERVICE;
         if(quantity > avaiableQuantity)
         {
              WANT TO SHOW ERROR TO THE USER AND
              SET QUANTITY to avaiableQuantity

         }
   }        


How can I show an error to the user?
Is ok to lower the ShoppingCartItem quantity setting
eventMessage.Entity.Quantity = avaiableQuantity;

?
Thank you very much.
8 年 前
pm40 wrote:
Hi, I'm coding a plugin that implements IConsumer EntityInserted<ShoppingCartItem>

When a product is inserted in the cart I check if the current avaiability is bigger or equal to the requested quantity.


public void HandleEvent(EntityInserted<ShoppingCartItem> eventMessage)
    {
         int quantity = eventMessage.Entity.Quantity;
         int avaiableQuantity= _REQUEST_TO_WEB_SERVICE;
         if(quantity > avaiableQuantity)
         {
              WANT TO SHOW ERROR TO THE USER AND
              SET QUANTITY to avaiableQuantity

         }
   }        


How can I show an error to the user?
Is ok to lower the ShoppingCartItem quantity setting
eventMessage.Entity.Quantity = avaiableQuantity;

?
Thank you very much.


throw new ArgumentNullException("filterContext");

Catch the exception on the controller. Send the infromation to view. And show error message using javascript.
8 年 前
pm40 wrote:
Hi, I'm coding a plugin that implements IConsumer EntityInserted<ShoppingCartItem>

When a product is inserted in the cart I check if the current avaiability is bigger or equal to the requested quantity.


public void HandleEvent(EntityInserted<ShoppingCartItem> eventMessage)
    {
         int quantity = eventMessage.Entity.Quantity;
         int avaiableQuantity= _REQUEST_TO_WEB_SERVICE;
         if(quantity > avaiableQuantity)
         {
              WANT TO SHOW ERROR TO THE USER AND
              SET QUANTITY to avaiableQuantity

         }
   }        


How can I show an error to the user?
Is ok to lower the ShoppingCartItem quantity setting
eventMessage.Entity.Quantity = avaiableQuantity;

?
Thank you very much.



You can use following method in your plugin/controller for friendly error messagebox showing.

ErrorNotification(_localizationService.GetResource("your.customer.error.message"), true);
6 年 前
calacula wrote:
Hi, I'm coding a plugin that implements IConsumer EntityInserted<ShoppingCartItem>

When a product is inserted in the cart I check if the current avaiability is bigger or equal to the requested quantity.


public void HandleEvent(EntityInserted<ShoppingCartItem> eventMessage)
    {
         int quantity = eventMessage.Entity.Quantity;
         int avaiableQuantity= _REQUEST_TO_WEB_SERVICE;
         if(quantity > avaiableQuantity)
         {
              WANT TO SHOW ERROR TO THE USER AND
              SET QUANTITY to avaiableQuantity

         }
   }        


How can I show an error to the user?
Is ok to lower the ShoppingCartItem quantity setting
eventMessage.Entity.Quantity = avaiableQuantity;

?
Thank you very much.


You can use following method in your plugin/controller for friendly error messagebox showing.

ErrorNotification(_localizationService.GetResource("your.customer.error.message"), true);


I have checked this Its not working. Is there anything that i am missing?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.