Bills and Recurring Billing

Top  Previous  Next

To create a bill and send an invoice, begin by creating a quote and then convert the quote into a bill. When a bill is created an invoice may be emailed to the customer. The invoice will automatically include the order reference number and a link to pay online through the shopping cart checkout/payment pages.




A bill may be one-time or recurring. If it is recurring, a new bill will be automatically created and emailed to the customer on a schedule, which is set in the edit bill page. Recurring bills may be set to stop after a specific number of billing cycles or they may be set to continue indefinitely.




The Due Date appears at the bottom of invoices and it is used as a reference for sending reminders, past due messages, and recurring bills.


For service from: %startdate% to: %enddate% - These dates are used by the tokens in the Add Comment field (below). The first invoice will use the dates that are set when the bill is first created. If the bill is recurring, the dates will automatically increment for each billing cycle based on the length of the billing cycle. For example with monthly recurring bills the next automatically generated invoice will include from/to dates that are one month after the from/to dates of the previous invoice.


Add Comment - A comment may be included in each invoice. Tokens may be used to include variable content such as dates and order related data. To omit the comment from invoices, leave this field blank.


Remind (number of days) before due date if not paid - Check the box to enable the reminder message and enter a number of days that is appropriate for the billing cycle. For example if the recurring invoice is to be created and sent 10 days before the due date for each billing cycle, the reminder message can be sent within 1 to 10 days of the due date.


Reminder messages will not be sent for bills that have already been paid.
A reminder cannot be sent before the invoice is sent. If the Remind (number of days) is set to a value that is before the date that the bill will be sent,  there will be a pop up error message and the setting will not be saved.
The reminder will never be sent if it is time to send the past due message. For example; if the cron job for autobill.php has been inactive for a while.


Reminder Message - The reminder message text is included in reminder messages that are automatically sent and also in reminders that are manually sent from Sales Reports (for Unpaid orders in Edit mode). Tokens may be used to include variable content such as dates and order related data.


Send Past Due Message (number of days) after due date if not paid - When the box is checked, a past due message will be automatically generated and sent the set number of days after the due date. Past due messages are not sent for bills that have already been paid.


Past Due Message - This text is included in automatically generated past due messages. Tokens may be used to include variable content such as dates and order related data.


Recurring options are None, Weekly, Monthly, Quarterly, Semiannually or Annually. After the first bill sent, recurring bills will be automatically created and sent based upon the cycle that is set for Recurring. AutoBill will calculate the date to send the next recurring bill by first figuring out its due date and then subtracting the "send x days before due date" from it. If "send x days before due date" is set to zero, the next bill will be sent on the next due date.


Repeat number of times - This is how many times automatic recurring bills will be created and sent. This does not include the first bill, which was manually created or created from a shopping cart order with a recurring bill template. Set the number of times to zero if the recurring bills are to continue indefinitely.


Create and send bill (number of days) before due date - Automatic recurring bills are typically created and sent before the due date so that customers have adequate time to pay before the bill becomes past due. The number of days set here should be greater than the Reminder Message number of days.


Tokens are placeholders where variable data is inserted into the message text by the program.


%startdate% - The beginning date of period of time for which the service is being billed.

%enddate% - The ending date of the period of time for which the service is being billed.

%duedate% - This is the due date for each bill.



The %startdate%, %enddate%, and %duedate% values are initially set when a new bill is created. For recurring bills, the dates are automatically incremented with each billing cycle.


AutoBill - Automatic Recurring Bills


To generate new automatic recurring bills and to send reminder and past due messages the emerchant/autobill.php script should be run.


Before running autobill.php,  open the script in a text editor and set the server path. Do not remove the quotes or the semicolon around the path setting. Do not edit anything else in this file.




To run autobill.php automatically on a daily schedule, set up a Cron. Set the Crontab to run every day. If there are other Crons scheduled for the same domain, set this one to run at a different time so that potential conflicts are avoided. Here is an example of a Cron command to run autobill.php.

/usr/bin/php -q /home/httpd/vhosts/


Typical Cron Setup in Plesk



Daily AutoBill Reports


Each time autobill.php runs, a report is sent to the Sales Office customer inbox. When the Cron runs, an AutoBill Cron Job Report is sent. When new bills, reminders and past due messages are sent, an AutoBill Activity report is sent to the Sales Office customer inbox. The daily activity reports help to insure that the Cron is running and that the bills are being processed consistently. To daily AutoBill report data is saved in the database table: emerchant_autobillreport, which may be browsed using phpMyAdmin or a similar tool. (Most hosting services provide phpByAdmin or a similar database management tool.)


Billing Templates


Billing templates are used to automatically create recurring bills from orders. See Sales Office > Billing Templates.


Managing Unpaid Orders


Unpaid Orders are reported in the admin panel under Sales Reports. Select status Unpaid and Edit mode to manage unpaid orders and to send reminders. Unpaid orders also appear in each related customer's history through Sales Office.