X-Cart:Cron.php - Script for Periodic Tasks
X-Cart provides a script cron.php which you can use to launch the execution of periodic tasks.
The tasks include:
- Checking whether an authorization has expired for any payment transactions in Pre-authorized status and setting the status of the respective orders to Declined.
- Checking whether an authorization is going to expire for any payment transactions in Pre-authorized status and sending email notifications thereof to the store's Orders department. See more info on the setting "Number of days in advance that you want a reminder to be sent..." here.
- Sending out survey invitations (X-Survey).
- Sending out abandoned cart reminder notifications (Abandoned Cart Reminder in automated mode).
To run the script cron.php, use one of the following methods:
- Run cron.php from the command line (For example, use system cron to launch cron.php via crontab).
- Configure X-Cart to launch cron.php automatically.
The first method - launching the script from the command line - enables you to exactly set the time when the script needs to be launched.
The second method relies on X-Cart's session mechanism. It enables you to specify the frequency of cron.php execution in connection with X-Cart user sessions: the script will be launched once per a predetermined number of user sessions; you get to set the number of sessions.
If you decide to configure X-Cart to launch cron.php automatically in connection with user sessions, you will only need to adjust the setting 'Run the script that launches execution of periodic tasks once per N user sessions' in the 'General Settings/General options' section specifying the desired number of user sessions.
If you choose to launch the script from the command line, be sure to:
- Set a secret key for running cron.php. This can be done using the setting 'Key for launch of the cron.php script' in the 'General Settings/General options' section of X-Cart Admin.
- Keep the field 'Run the script that launches execution of periodic tasks once per N user sessions' in the 'General Settings/General options' section set to the default value of "0" (zero). This tells X-Cart that you do not wish to use its sessions mechanism to determine when to run cron.php.
- Run the script cron.php from the command line (for example, via crontab) no more than once every 30 minutes.
Here's an example of a command to launch cron.php:
cd /var/www/vhosts/yoursite.com/httpdocs/xcart; /usr/bin/php -d safe_mode=Off cron.php --key=c901d65fc15ff15d0ac0af967437d051
Note that you need to run cron.php using the so called "CLI" version of PHP. Ask your hosting administrator to tell you the location of PHP CLI on your server and configure cron to run the cron.php script using PHP CLI version.