CartThrob Invoice Version 1.0103
Overview
CartThrob Invoice lets you create invoices in the ExpressionEngine control panel, send invoice emails, and let customers add invoices directly to cart for checkout.
In 1.0103 code:
- invoices are stored in
cartthrob_invoice_table - invoice settings/templates are stored in
cartthrob_invoice_settings - invoice pay links/forms route through CartThrob
add_to_cart_action - paid invoices are marked during
cartthrob_on_authorize
Requirements
From bundled docs in this release package:
- ExpressionEngine 2.5+
- CartThrob 2.2+
- PHP 5.3+
Installation
- Upload
/system/expressionengine/third_party/cartthrob_invoice/. - Install
CartThrob Invoicefrom the Add-ons page. - Open Invoice CP and run
Installationto install the bundledinvoicestemplate group. - Configure
Settingsbefore sending invoices.
Upgrading
- Upload the updated
cartthrob_invoicefolder over existing files. - Run add-on updates in EE Add-ons.
- Recheck Invoice
Settingstemplate selections and admin email.
Start Here (10-Minute Setup)
- Open
Add-ons > CartThrob Invoice > Settings. - Set:
- Invoice Administrator Email Address
- Invoice Email Template
- Invoice Update Email Template
- Payment Reminder Email Template
- Cancellation Email Template
- Invoice Paid Email Template
3. Open Add and create one invoice with:
- project title
- total cost
- status pending
- customer email address
4. Save and go to View.
5. Click Send for the invoice.
6. In the email/template output, use the invoice pay link (purchase_invoice_link) and complete checkout.
7. Confirm invoice status becomes paid after authorization.
Common Tasks With Examples
1. Send A New Invoice
- Create invoice in
Add. - In
View, clickSend. - Customer receives template from
template_send.
2. Send Reminder Or Update
- In
View, clickRemindorUpdate. - Reminder uses
template_remind. - Update uses
template_update.
3. Cancel Invoice
- In
View, clickCancel. - On delete confirmation page, keep
deletechecked and submit. - Cancellation email is sent via
template_cancelbefore deletion path completes.
4. Print Invoice
- In
View, clickPrint. - Opens rendered template (uses
template_sendin current implementation) in a new tab.
Quick Links For Existing Users
- Need invoice grid/actions: see Invoice List (View)
- Need settings fields: see System Settings
- Need status/update behavior: see Notifications and Invoice Lifecycle
- Need tag details: see Template Tags
Control Panel Reference
Base module path: C=addons_modules&M=show_module_cp&module=cartthrob_invoice
Navigation
Main CP methods:
system_settingsviewaddeditdeleteinstallation
System Settings
Route method: system_settings
Fields:
Order Channel Invoice ID field(order_channel_invoice_id_field)
- Select field key used to store invoice id on the order.
Invoice Administrator Email Address(admin_email_address)
- Sender/from and admin recipient for invoice events.
Invoice Email Template(template_send)
- Default: invoices/email_send
Invoice Update Email Template(template_update)
- Default: invoices/email_update
Payment Reminder Email Template(template_remind)
- Default: invoices/email_remind
Cancellation Email Template(template_cancel)
- Default: invoices/email_cancel
Invoice Paid Email Template(template_paid)
- Default: invoices/email_paid
Add Invoice
Route method: add
Form fields:
Project Title(inv_title)Total Cost(inv_cost)Total Hours(inv_total_hours)Status(inv_status) : options arepending,in_progress,paid,closed,canceledProject Description(inv_description)Member ID(inv_member_id)Reference Number(inv_reference_number)- address block:
:
inv_first_name,inv_last_name,inv_email_address,inv_phone,inv_company,inv_address,inv_address2,inv_city,inv_state,inv_zip,inv_country_code - line items matrix (
inv_line_items) : columnsitem_title,item_description,hours,item_cost
Submit action: add_invoice
Behavior:
- new invoices set
inv_dateto current timestamp - invoice record is written via
invoices_model->update()
Edit Invoice
Route method: edit
Same core fields as Add, plus:
- hidden
id Order ID(inv_order_id)
Submit action: add_invoice
Behavior:
- when status changes to
paid,inv_paid_dateis set (if not already set) - if status is not
paid,inv_paid_dateis cleared (NULL)
Invoice List (View)
Route method: view
Filter form:
filter_statusdropdown- statuses plus blank option (
--)
Table columns:
IDTitleCostTotal HoursCreatedPaidOrder IDMember IDStatusActions
Row actions:
Edit-> openseditfor invoice idCancel-> opensdeleteconfirmation for invoice idPrint-> opensprint_invoicein new tab/windowSend-> executesnotify_actionUpdate-> executesupdate_actionRemind-> executesremind_action
Delete Invoice
Route method: delete
Form behavior:
- shows delete checkbox (
delete=yes, checked by default) - submits through
form_update
Additional behavior in form_update:
- on delete path, attempts cancellation email (
template_cancel) before record update/delete handling
Installation Utility
Routes:
installationdo_installation
Behavior:
- reads installer package definitions from
installer/installer.xml - installs selected template groups/templates
- bundled template group:
invoices - bundled templates:
:
index,email_send,email_update,email_remind,email_cancel,email_paid
Notifications and Invoice Lifecycle
Extension Hooks Registered
From updater hook list:
cartthrob_on_authorizecartthrob_addon_registercartthrob_add_to_cart_endcartthrob_add_to_cart_start
Add-To-Cart Invoice Flow
- Invoice link/form provides encoded
INVvalue. cartthrob_add_to_cart_startdecodesINVand prepares POST data.- Validations:
- prevents same invoice being added multiple times
- blocks already paid invoices
4. Injects cartthrob add-to-cart POST values:
- price (PR)
- title
- one-time fee (OTF)
- no-tax (NTX)
- no-shipping (NSH)
5. cartthrob_add_to_cart_end stores invoice id in item meta invoice_number.
Payment Authorization Flow
On cartthrob_on_authorize:
- invoice items in cart are detected by
invoice_numbermeta - invoice row is updated:
inv_status = paidinv_member_id = current memberinv_order_id = order entry idinv_paid_date = now- paid email template (
template_paid) can be sent to admin and customer - if
order_channel_invoice_id_fieldis configured, order is updated with invoice id
Email Actions
CP actions and default templates:
notify_action->template_sendupdate_action->template_updateremind_action->template_remind- delete path in
form_update->template_cancel - authorize hook ->
template_paid
Note:
update_actioncustom event lookup uses_send_remindersuffix in code, even though the action is update.
Template Tags
Tags are used through CartThrob tag namespace in this release package:
{exp:cartthrob:invoice}{exp:cartthrob:invoice_items}{exp:cartthrob:purchase_invoice_form}{exp:cartthrob:purchase_invoice_link}
invoice
Outputs one invoice record.
Parameters:
invoice_number(string/int)invoice_id(alias for invoice number)
Variables:
- all scalar invoice table columns, including:
idinv_descriptioninv_titleinv_cost(formatted with number library)inv_total_hoursinv_statusinv_dateinv_paid_dateinv_email_addressinv_member_idinv_order_idinv_reference_numberinv_first_nameinv_last_nameinv_companyinv_addressinv_address2inv_cityinv_stateinv_zipinv_country_codeinv_phone- added aliases:
invoice_numberinvoice_id
Conditionals:
{if no_results}...{/if}when invoice is missing/invalid
invoice_items
Loops line items for one invoice.
Parameters:
invoice_numberinvoice_id(alias)
Variables:
item_titleitem_descriptionhoursitem_costinvoice_count(1-based row index)invoice_total_results(total line-item count)
Conditionals:
{if no_results}...{/if}for missing/empty items
purchase_invoice_form
Outputs a CartThrob add-to-cart form configured for invoices.
Parameters:
invoice_number(required)invoice_id(alias)return(optional)language(optional)- additional CartThrob add-to-cart params are passed through
Behavior:
- sets hidden
INVtoken - posts to CartThrob
add_to_cart_action
purchase_invoice_link
Outputs direct URL to add invoice to cart.
Parameters:
invoice_number(required)invoice_id(alias)return(optional return path)
Behavior:
- builds URL with CartThrob
ACTid - encodes invoice token in
INV
Changelog
Release baseline for this documentation pass:
Version 1.0103
Version note:
- Live docs page headline shows
1.013; this documentation targets1.0103.