I'm using rules scheduler (on D7) to set up a reminder email based on a time specified within a commerce order (more specifically a line item in the order). I was able to get everything set up correctly using these instructions, so that the email is scheduled and send out. However, I am having a problem with the actual content of the email appearing correctly.
Just to clarify the rule setup, the flow is
- Line item is updated
- Rules scheduler schedules a component to run based on line item's date field
- When the scheduled time is hit, the component is triggered
- A view that serves the list of users is loaded
- Component loops through list of users in the view
- Email is sent to each user
The content of the email is defined by another view, which I am embedding using:
<?php $id = $line_item->line_item_id; print views_embed_view('commerce_checkout_page_for_email_embed', 'block_4', $id); ?>
The $id above is used to pass the line item's ID into the view to filter results by the current line item.
In my testing, when triggering the component directly on Line Item Update instead of at a scheduled time, everything works perfectly. The email is sent, and the body of the email contains the proper view filtered by the current line item.
However, when the email is sent by rules scheduler, the body of the email is empty. When I hard code
$id=1776 instead of
$id = $line_item->line_item_id) the body of the email is exactly as it is supposed to be. I can only assume that this means that for some reason, the scheduled rule is not able to access the variable I'm passing to it. I also tried passing the token for the line item id, but you cannot pass token in PHP, so that was a bust.
Does anybody know why this might be, or have any suggestions?