Ok M., thank you for reply, but still not clear your explanations; please note that last_check is updated in preferences table at each hourly cron so the timeframe between $from & $to will be x day + 1 hour maximum.
Let assume that the email reminders, all of them which ends with "...soon" are set-up at 3 days.
This means that $from will be $today (2023-09-30) - 3 days = 2023-09-27
Also the $to will be 2023-09-27 but plus few minutes, between 0 and 60 if you manually run cron, or exactly 60 if leave the cron to run by server.
Then the:
$promotions = ModelERM::newInstance()->getOspPromotionAboutExpiration($from, $to);
will look in database table oc_t_osp_item al promotions which have expiration date in interval [from - to], I mean "in the past"
Anyway, I suggest to stop here and do some tests myself.
I have installed a fresh copy OSC 8.1.2 and 2 plugins (OSC Pay & Email reminder) on an empty domain.
Setting up crons in Cpanel
Disabled the option "Warn about expiration" in main OSC settings: Listings -> Settings, in order not to mix up with plugin option
Set in "For sale" category the duration to be 3 days in order to reduce the time for tracking/analyzing
Made few adjustements in osc_pay plugin in order to test also "membership expire soon" and "promotion expire soon"
Set in Email Reminder plugin only 3 alerts: "item expire soon", "membership expire soon" and "promotion expire soon" with value "1" so with 1 day before expiration should send alert that WILL expire.
On 2023-09-30 I have done:
- Registered the user
- bought Silver membership (valid only for 2 days; will expire 2023-10-02 11:26:03)
- added one listing (valid only for 3 days but after that I modified in database to expire after 2 days and 4 hours in order NOT to be catched by same cron together with membership reminder, so will expire on 2023-10-02 15:34:50)
- promote as "Premium" that listing. (valid only for 2 days, will expire 2023-10-02 13:39:08)
- took screen capture from 3 tables in database to show their date of expiration (item, membership, premium) if someone will ask me
What to expect:
Considering today is 2023-09-30 and all 3 reminders to observe will need to be fired with 1 day before as is set on plugin EMR settings, also all 3 of them have expiration date 2023-10-02, then tomorow 2023-10-01 the test user will receive 3 email alerts, each one informing that something is about to expire, at different hours as I made small adjustements of hour in order not to receive all emails once.
Let see...