Close

Custom Rules

hristian.dimov
9 years ago
#10085 Quote
Avatar
  • Moderator
  • 386
IvanSlater wrote:
I created a couple new rules and I need to make some customizations on your abandoned card rule. Is it possible to share your rule code with me? Can send it to my email ? I will be glad!

Nop 3.3 and 3.6 (if possible).

Thanks!


Hi IvanSlater,

Please contact our sales at [email protected] for more information.

But keep in mind that we don't have such practice to share the source code of our plugins due to many attempts of copying our products.

Hope this helps!
Regards,
Hristian Dimov
Nop-Templates.com
IvanSlater
9 years ago
#10152 Quote
Avatar
  • 89
Hi!

I have created a new custom rule for abandoned cart, but there is a problem, it doesnt send e-mails or add entries to reminder's report. I have other rules working fine, just it doesnt work. Better, can you verify my code, please?

When deguggig, there is data and result contains all message info to send, but after method return, nothing happens. I have changed all rule conditions, but no results anyway.


                var customerReminderInfos = new List<CustomerReminderInfo>();

                var _from = DateTime.Now.AddMinutes((int)conditionMetDateLaterThan.TotalMinutes * -1);
                var _to = DateTime.Now.AddMinutes((int)conditionMetDataEarlierThan.TotalMinutes * -1);

                var query = from sci in _sciRepository.Table
                            where sci.UpdatedOnUtc >= _from
                               && sci.UpdatedOnUtc <= _to
                               && sci.ShoppingCartTypeId == 1
                               && sci.StoreId == storeId
                            select sci;

                var cartItems = query.ToList();

                var customers = cartItems.Select(p => p.Customer).Distinct().ToList();

                foreach (var customer in customers)
                {
                    if (!customer.IsRegistered())
                        continue;

                    var tokens = GetTokens(customer, store);

                    var customerReminderInfo = new CustomerReminderInfo()
                    {
                        Customer = customer,
                        ReminderMessageId = customer.Id,
                        RuleConditionMetDate = DateTime.Now,
                        Tokens = tokens,
                        StoreId = storeId
                    };

                    customerReminderInfos.Add(customerReminderInfo);
                }

                return customerReminderInfos;


Thanks!
hristian.dimov
9 years ago
#10154 Quote
Avatar
  • Moderator
  • 386
IvanSlater wrote:
Hi!

I have created a new custom rule for abandoned cart, but there is a problem, it doesnt send e-mails or add entries to reminder's report. I have other rules working fine, just it doesnt work. Better, can you verify my code, please?

When deguggig, there is data and result contains all message info to send, but after method return, nothing happens. I have changed all rule conditions, but no results anyway.


                var customerReminderInfos = new List<CustomerReminderInfo>();

                var _from = DateTime.Now.AddMinutes((int)conditionMetDateLaterThan.TotalMinutes * -1);
                var _to = DateTime.Now.AddMinutes((int)conditionMetDataEarlierThan.TotalMinutes * -1);

                var query = from sci in _sciRepository.Table
                            where sci.UpdatedOnUtc >= _from
                               && sci.UpdatedOnUtc <= _to
                               && sci.ShoppingCartTypeId == 1
                               && sci.StoreId == storeId
                            select sci;

                var cartItems = query.ToList();

                var customers = cartItems.Select(p => p.Customer).Distinct().ToList();

                foreach (var customer in customers)
                {
                    if (!customer.IsRegistered())
                        continue;

                    var tokens = GetTokens(customer, store);

                    var customerReminderInfo = new CustomerReminderInfo()
                    {
                        Customer = customer,
                        ReminderMessageId = customer.Id,
                        RuleConditionMetDate = DateTime.Now,
                        Tokens = tokens,
                        StoreId = storeId
                    };

                    customerReminderInfos.Add(customerReminderInfo);
                }

                return customerReminderInfos;


Thanks!


Hi,

the problem is in this line: RuleConditionMetDate = DateTime.Now,

It should be the date when the event has happened, not DateTime.Now. In your case it should be the created/updated date of the last shopping cart item for the given customer.

Hope this helps!
Regards,
Hristian Dimov
Nop-Templates.com
IvanSlater
9 years ago
#10227 Quote
Avatar
  • 89
Working great, thanks.

Now, when I edit an old rule, this error appears:

System.InvalidOperationException: Sequence contains no matching element at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate) at SevenSpikes.Nop.Plugins.CustomerReminders.Controllers.CustomerRemindersAdminController.RF1sHprQV(String ) at SevenSpikes.Nop.Plugins.CustomerReminders.Controllers.CustomerRemindersAdminController.gFyFtq2rt(String , Int32 ) at SevenSpikes.Nop.Plugins.CustomerReminders.Controllers.CustomerRemindersAdminController.Edit(Int32 id) at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End() at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass48.<InvokeActionMethodFilterAsynchronouslyRecursive>b__41() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass48.<InvokeActionMethodFilterAsynchronouslyRecursive>b__41() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass48.<InvokeActionMethodFilterAsynchronouslyRecursive>b__41() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass48.<InvokeActionMethodFilterAsynchronouslyRecursive>b__41() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass48.<InvokeActionMethodFilterAsynchronouslyRecursive>b__41() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass48.<InvokeActionMethodFilterAsynchronouslyRecursive>b__41() at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End() at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)

/admin/customerremindersadmin/edit/3

This reminder is no longer being executed. Only other remindes.

Ivan.
hristian.dimov
9 years ago
#10236 Quote
Avatar
  • Moderator
  • 386
IvanSlater wrote:
Working great, thanks.

Now, when I edit an old rule, this error appears:

System.InvalidOperationException: Sequence contains no matching element at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate) at SevenSpikes.Nop.Plugins.CustomerReminders.Controllers.CustomerRemindersAdminController.RF1sHprQV(String ) at SevenSpikes.Nop.Plugins.CustomerReminders.Controllers.CustomerRemindersAdminController.gFyFtq2rt(String , Int32 ) at SevenSpikes.Nop.Plugins.CustomerReminders.Controllers.CustomerRemindersAdminController.Edit(Int32 id) at lambda_method(Closure , ControllerBase , Object[] ) at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End() at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass48.<InvokeActionMethodFilterAsynchronouslyRecursive>b__41() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass48.<InvokeActionMethodFilterAsynchronouslyRecursive>b__41() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass48.<InvokeActionMethodFilterAsynchronouslyRecursive>b__41() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass48.<InvokeActionMethodFilterAsynchronouslyRecursive>b__41() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass48.<InvokeActionMethodFilterAsynchronouslyRecursive>b__41() at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass48.<InvokeActionMethodFilterAsynchronouslyRecursive>b__41() at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End() at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)

/admin/customerremindersadmin/edit/3

This reminder is no longer being executed. Only other remindes.

Ivan.


Hi Ivan,

Could you please check if this reminder rule is still inheriting the IReminderRule interface? Also, double-check if the reminder rule is registered in DependencyRegistrar file.

Looking forward to your reply!
Regards,
Hristian Dimov
Nop-Templates.com
IvanSlater
9 years ago
#10240 Quote
Avatar
  • 89
The problem was in DependencyRegistrar. The rule's line was missed!

Thanks a lot again!
IvanSlater
8 years ago
#12746 Quote
Avatar
  • 89
All my custom roles started to thrown an exception after upgrade them to 3.7 version, running on web farm.

Error while running the 'Customer Reminders Task' schedule task. Nullable object must have a value.

System.InvalidOperationException: Nullable object must have a value. at Nop.Plugin.Misc.NewReminderRules.MakeCommentRulesService.GetCustomerReminderInfos(TimeSpan conditionMetDataEarlierThan, TimeSpan conditionMetDateLaterThan, Int32 storeId, Int32 reminderId) at SevenSpikes.Nop.Plugins.CustomerReminders.Services.RemindersProcessor.KaeWsmUPqS() at SevenSpikes.Nop.Plugins.CustomerReminders.Services.RemindersProcessor.ProcessReminders() at SevenSpikes.Nop.Plugins.CustomerReminders.Tasks.CustomerRemindersTask.TG3VfSGZunBWJvkN9My(Object ) at SevenSpikes.Nop.Plugins.CustomerReminders.Tasks.CustomerRemindersTask.Execute() at Nop.Services.Tasks.Task.Execute(Boolean throwException, Boolean dispose, Boolean ensureRunOnOneWebFarmInstance)

Is it a CustomerReminder plugin bug? Is it related to web farm?

Can you help?

Thanks
IvanSlater
8 years ago
#12747 Quote
Avatar
  • 89
Staff, any help on it?
anton_ivanov
8 years ago
#12748 Quote
Avatar
  • Moderator
  • 277
Hello Ivan,

We cannot seem to reproduce your problem. Can you submit a ticket with admin credentials in order to further investigate it ?
Regards,
Anton Ivanov
Nop-Templates.com