Geo Plugin

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
Hi everyone,
I developed a pluging to choose the store where you pick up the goods.
When the OnePageCheckout start, rather than selecting the shipping address, you can browse the map and choose the store nearest to you, everything worked out fine and when submit I receive "store id" instead of the "address id".

I created a method into my plugin controller to add a new shipping address egual to store address by id, and i would call OpcSaveShipping() with new created id.
.
I inserted a FilterAction at OpcSaveShipping to encode the address of the client, but my problem is that I can't launch action into my plugin controller from the FilterAction, but I can i.e. an action in Checkout Controller.

       
public void RegisterRoutes(RouteCollection routes)
        {
            routes.MapRoute("gommisti-list",
                  "Gommisti/{action}/{id}",
                  new { controller = "Gommisti", action = "List", id = "" },
                  new[] { "Nop.Plugin.Shipping.Gommisti.Controllers" }
             );          
        }


and into OnActionExecuting


            filterContext.Result =  new RedirectToRouteResult(new RouteValueDictionary(new
            {
                controller = "Gommisti",
                action = "CodeShipToGommista",
                values = new { id_gommista = gommistaId }
            }));
            return;


Please, help me, why not fire??

Thanks a lot in advance.
11 years ago
sviluppoeconsulenza wrote:
Hi everyone,
I developed a pluging to choose the store where you pick up the goods.
When the OnePageCheckout start, rather than selecting the shipping address, you can browse the map and choose the store nearest to you, everything worked out fine and when submit I receive "store id" instead of the "address id".

I created a method into my plugin controller to add a new shipping address egual to store address by id, and i would call OpcSaveShipping() with new created id.
.
I inserted a FilterAction at OpcSaveShipping to encode the address of the client, but my problem is that I can't launch action into my plugin controller from the FilterAction, but I can i.e. an action in Checkout Controller.

       
public void RegisterRoutes(RouteCollection routes)
        {
            routes.MapRoute("gommisti-list",
                  "Gommisti/{action}/{id}",
                  new { controller = "Gommisti", action = "List", id = "" },
                  new[] { "Nop.Plugin.Shipping.Gommisti.Controllers" }
             );          
        }


and into OnActionExecuting


            filterContext.Result =  new RedirectToRouteResult(new RouteValueDictionary(new
            {
                controller = "Gommisti",
                action = "CodeShipToGommista",
                values = new { id_gommista = gommistaId }
            }));
            return;


Please, help me, why not fire??

Thanks a lot in advance.


You need to register the Filter, and I recommend using a Filter Provider. See this post: https://www.nopcommerce.com/boards/t/19724/how-to-load-cshtml-file-from-plugin.aspx
11 years ago
Thanks, I had already read the post recommended and I recorded the filter, my big problem is that into OnActionExecuting it works if I call a method into CheckoutController but does not work if I call a method in the controller of my plugin.


        public IEnumerable<Filter> GetFilters(ControllerContext controllerContext,
            ActionDescriptor actionDescriptor)
        {
            if (actionDescriptor.ControllerDescriptor.ControllerType == typeof(CheckoutController) &&
                actionDescriptor.ActionName.Equals("OpcSaveShipping") &&
                controllerContext.HttpContext.Request.HttpMethod == "POST")
            {
                return new Filter[]
            {
                new Filter(_actionFilter, FilterScope.Action, null)
            };
            }

            return new Filter[] { };
        }


http://www.impaginando.it/job/snapshot/geo_plugin.jpg
11 years ago
Solved. I have used [ValidateInput(false)] before my action declaration...


[ValidateInput(false)]
public ActionResult CodeShipToGommista(FormCollection form)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.