IvanSlater wrote:Hi Hristian,
thanks a lot. Do you have a simple sample? I need to create another plugin, a "rule plugin", is it right?
EDIT:
I have created a new plugin with all my new rules. Now, can you say more about both interface methods:
- GetAllowedTokens
- GetCustomerReminderInfos
I guess they are called at each task call, am I right? The CustomerReminderInfo list returned are all items that will received the message?
And about the tokens, if I create a new one, where it have to be replaced? Or is not possible to have new ones?
Thanks!
Yes, you can done it with a plugin.
Example of The CustomerReminderInfos method:
public IList<CustomerReminderInfo> GetCustomerReminderInfos(TimeSpan conditionMetDataEarlierThan, TimeSpan conditionMetDateLaterThan, int storeId)
{
var customerReminderInfos = new List<CustomerReminderInfo>();
//perform your logic for selecting the data that you need
IList<global::Nop.Core.Domain.Customers.Customer> inactiveCustomers = GetInactiveCustomers(conditionMetDataEarlierThan, conditionMetDateLaterThan);
foreach(var customer in inactiveCustomers)
{
var customerReminderInfo = new CustomerReminderInfo()
{
Customer = customer,
ReminderMessageId = customer.Id,
RuleConditionMetDate = customer.CreatedOnUtc,
Tokens = GetTokens(customer), // or you can leave it as "new List<Token>()"
StoreId = storeId
};
customerReminderInfos.Add(customerReminderInfo);
}
return customerReminderInfos;
}
private IList<Token> GetTokens(Customer customer)
{
var tokens = new List<Token>();
tokens.Add(new Token("Customer.FullName", customer.GetFullName()));
return tokens;
}
and yes, you can create new tokens, but you must evaluate them in the GetTokens method, just like the example above.
GetAllowedTokens method example:
public IList<string> GetAllowedTokens()
{
var allowedTokens = new List<string>()
{
"%Customer.FullName%"
};
return allowedTokens;
}
Hope this helps!