How to intercept event in checkout process to check product attributes?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 9 años
For some unclear reason I receive:
"Failed to add the product to the cart. Please refresh the page and try one more time."

the filter works fine for the products to be filtered on, but the onces that pass the filter fail. Any idea?
Hace 9 años
Quantis001 wrote:
For some unclear reason I receive:
"Failed to add the product to the cart. Please refresh the page and try one more time."

the filter works fine for the products to be filtered on, but the onces that pass the filter fail. Any idea?


It's hard to comment without debugging info / more in-depth error message. Please use breakpoint to step through the code. :)
Hace 9 años
Hi,

If I remove the custom IFilter I hit the breakpoint. I see in filtercontext that Result = null. Can it be that return new List<Filter>(); should not be empty?

J.


    protected IEnumerable<Filter> GetFilters(string controllerNameContext, string actionNameContext)
        {
            if (IsMatch(controllerNameContext, actionNameContext))
                return new List<Filter>() { new Filter(this, FilterScope.Action, 0) };
            else
                return new List<Filter>();
        }
Hace 9 años
Quantis001 wrote:
Hi,

If I remove the custom IFilter I hit the breakpoint. I see in filtercontext that Result = null. Can it be that return new List<Filter>(); should not be empty?

J.


    protected IEnumerable<Filter> GetFilters(string controllerNameContext, string actionNameContext)
        {
            if (IsMatch(controllerNameContext, actionNameContext))
                return new List<Filter>() { new Filter(this, FilterScope.Action, 0) };
            else
                return new List<Filter>();
        }


You can return an empty List, that means you don't want to register any filter. :)
Hace 9 años
Hi,

I have also a filterAttribute on the Checkout. There is works without any problem. However, AddProductToCart_Details and AddProductToCart_Catalog give this error. If I do not register the Filters, the items are added to the cart. Can it have something to do with AJAX or httppost or cache?

J.
Hace 9 años
Quantis001 wrote:
Hi,

I have also a filterAttribute on the Checkout. There is works without any problem. However, AddProductToCart_Details and AddProductToCart_Catalog give this error. If I do not register the Filters, the items are added to the cart. Can it have something to do with AJAX or httppost or cache?

J.


You really need to put a breakpoint on your custom addtocart method, and see what is happening. There are too many possibilities. :)
Hace 9 años
Hi,

Thank you for keeping point out to the debugger. I ran it again and found that it is indeed a 'caching' issue.

Or better, Single() should not be used since not all products are lease products :-(. So changed it to FirstorDefault().

THANK YOU FOR KEEPING ME SHARP(ER)!

J.


      public LeaseProduct GetByPayeeIdProductId(int payeeId, int productId)
        {                        
            string key = string.Format(LEASEPRODUCTSERVICE_BY_PAYEEID_PRODUCTID_KEY, payeeId, productId);
            return _cacheManager.Get(key, () =>
            {
                var query = _leaseProductRepository.Table.Where(
                        x => x.PayeeId == payeeId && x.ProductId == productId).Single();

                return query;
            });
        }
Hace 6 años
Hi,

I have created a Plugin successfully. now i need to Capture Checkout Event and want to run some custom  code based on needs of my Plugin on Product CheckOut.

Any sort of help will be highly appreciated.

Thanks.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.