X-Cart:Cron.php - Script for Periodic Tasks

From X-Cart 4 Classic
Revision as of 17:23, 23 May 2017 by Aim (talk | contribs) (added It is recommended to leave this set to 0 and to run the script cron.php from the command line (for example, via crontab) no more than once per hour.)
Jump to: navigation, search

X-Cart provides a script cron.php which you can use to launch execution of periodic tasks.

The tasks include:

  • Checking whether authorization has expired for any payment transactions in Pre-authorized status and setting the status of the respective orders to Declined.
  • Checking whether authorization is going to expire for any payment transactions in Pre-authorized status and sending email notifications thereof to the store's Orders department.
    Note: You can define how many days in advance such notifications must be sent using the setting 'Number of days in advance that you want a reminder to be sent to the Orders department email address about an order in Pre-authorized status for which the authorization period is going to expire' in the 'General settings/General options' section.
  • Sending out survey invitations (when X-Survey add-on module is used).
  • Sending out abandoned cart reminder notifications (when Abandoned Cart Reminder add-on module is used in automated mode).

You can choose to launch the script cron.php from the command line or to set up X-Cart to launch this script automatically. Launching cron.php from the command line gives you a bit more control: you can decide exactly when you wish the script to be launched. Allowing X-Cart to launch this script automatically saves you time and effort: X-Cart will launch the script once per a predetermined number of user sessions.

If you choose to launch the script from the command line, you will need to adjust the setting 'Key for launch of the cron.php script' field in the 'General Settings/General options' section.

If you decide to set up X-Cart to launch cron.php automatically, you will 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. (It is recommended to leave this set to 0 and to run the script cron.php from the command line (for example, via crontab) no more than once per hour.)

Example of command line to launch the cron.php script:

cd /var/www/vhosts/yoursite.com/httpdocs/xcart; /usr/bin/php -d safe_mode=Off cron.php --key=c901d65fc15ff15d0ac0af967437d051
Note: 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.

See also