Close

Profile: ron.richardson

Avatar

User posts

9 years ago

I've built a custom rule, and it shows up just fine.  I've configured it and debugged it to verify that results are coming back.  However, nothing is getting queued up in the Reminders report.  As long as my query returns back values, it should be as simple as returning a List<CustomerReminderInfo> records from GetCustomerReminderInfos, right?  

Here is my partial code:


public IList<string> GetAllowedTokens()
{
  var allowedTokens = new List<string>()
  {
    "%Customer.FirstName%",
    "%Product.Name%"
  };
  return allowedTokens;
}




public IList<CustomerReminderInfo> GetCustomerReminderInfos(TimeSpan conditionMetDateEarlierThan, TimeSpan conditionMetDateLaterThan, int storeId)
{
  List<CustomerReminderInfo> reminders = new List<CustomerReminderInfo>();




  var currentDateTime = DateTime.UtcNow;
  var ts1 = Convert.ToInt32(conditionMetDateEarlierThan.TotalSeconds);
  var ts2 = Convert.ToInt32(conditionMetDateLaterThan.TotalSeconds);




  var reviewableProducts = (
    from o in _orderRepository.Table
    join oi in _orderItemRepository.Table on o.Id equals oi.OrderId
    join p in _productRepository.Table on oi.ProductId equals p.Id
    join c in _customerRepository.Table on o.CustomerId equals c.Id
    where
      o.OrderStatus == OrderStatus.Complete
      && o.PaymentStatus == PaymentStatus.Paid
      && _productReviewRepository.Table.Where(x => x.CustomerId == o.CustomerId && x.ProductId == oi.ProductId).Count() == 0
      && o.PaidDateUtc.HasValue
      && DateTime.UtcNow >= DbFunctions.AddSeconds(o.PaidDateUtc.Value, ts1)
      && DateTime.UtcNow < DbFunctions.AddSeconds(o.PaidDateUtc.Value, ts2)
    select new
    {
      Id = oi.Id,
      Customer = c,
      Product = p
    }
  );
  
  foreach (var x in reviewableProducts)
  {
    var reminder = new CustomerReminderInfo()
    {
      Customer = x.Customer,
      ReminderMessageId = x.Id,
      RuleConditionMetDate = DateTime.UtcNow,
      Tokens = GetTokens(x.Customer, x.Product),
      StoreId = storeId
    };
    reminders.Add(reminder);
  }




  return reminders;
}




private IList<Token> GetTokens(Customer customer, Product product)
{
  var tokens = new List<Token>();




  var firstName = _genericAttributeService.GetAttributesForEntity(customer.Id, "Customer")
            .Where(x => x.Key == SystemCustomerAttributeNames.FirstName)
            .Where(x => x.KeyGroup == "Customer")
            .Select(x => x.Value)
            .FirstOrDefault();
  
  
  tokens.Add(new Token("Customer.FirstName", firstName));
  tokens.Add(new Token("Product.Name", product.Name));




  return tokens;
}



Is there anything else I need to do to get the reminder emails to be added to the queue?  Like I said before, I've used the debugger and verified that the query returns records, and it returns back a List<> with the expected number of records.  Nothing gets added to SS_CR_CustomerReminderMessageRecord however or the Nop message queue.

9 years ago

I'm having a similar issue.  I only have one store, however, but once I apply a filter, it appears to be using a different _ProductBox.  We have ours customized to show "FREE" if a product is $0.00.  Once a filter is applied, it reverts back to showing $0.00.

I have a folder under Themes in the plugin for my theme, and inside that, I have Content and Views.  In the views folder I have the CategoryTemplate.ProductsInGridOrLines.cshtml file in there.

Shouldn't the plugin pick the correct _ProductBox view based on the current theme? Or is there something else needed to make that happen?

I am using version 3.4.

9 years ago

I would like to see another option for COndition Type for Topics.  I'd like to put a widget zone on the generic topics view, but be able to show different content in that widget zone on each page.

For example, on topic page A, show one image in the widget zone, but on topic page B show a different image in the same widget zone.

10 years ago

Has anyone created a new Reminder Rule?  If so, can you share some sample code?  I understand I need to implement SevenSpikes.Nop.Plugins.CustomerReminders.Services.IReminderRule and register it as a service, but seeing a sample implementation would be helpful.

10 years ago

If you are still willing to share your source code for a custom data source, I would appreciate it!

Bugs
10 years ago

I'm finding an issue with the multi-store functionality with a new widget I created.  I created a simple sidebar image to act like an ad, and want it only on one of my stores, not both.  I edited the SupportedWidgetZones.xml file and uncommented the right_side_column_after widget zone and updated my widget to be placed in that zone.

In the Stores tab, I checked the limited to stores option and chose the 1 store I wanted it to show up in.  The widget correctly displays the item in the right sidebar, but it shows up on both stores.  There are no other conditions set on the widget.

I am only running the trial version, however. Not sure if this is a limitation to the trial or not.