Hello Instinct,
I needed this capability as well, so I figured out how to code it in X-Cart 4.0.19. Consider it another gift back to the wonderful X-Cart forums community.
Description: This code will allow you to send a SMS text message to a Cellphone when the order is received.
This is a great way for your site owner or admin to keep tabs on incoming sales even when they are away from the office.
Short Messaging Service (SMS) typically allows 150 to 160 characters maximum per message. You will need a cellphone and a subscription from your cellphone provider to receive text messages. Rates vary among providers. Some charge by message, other by kilobyte and others offer unlimited messaging plans.
NOTE: There are 2 versions of the (Step 1) code below... SMS initial order notifications, or SMS processed order notifications.
It's always advisable to backup any files you will be modifying.
Version 1: SMS Initial Order Notifications to Orders Department (i.e. Admin).
Advantage: You can turn the SMS messages on and off via the initial orders notifications setting in the Admin --> General Settings --> Email Notifications Options
STEP 1:
Locate file: include/func.php (for 4.0.x)... for
4.1.x, make the MODs to file:
include/func/func.order.php (note that the line numbers will be different, but code is the same)
Locate Code (Line 3206):
Code:
# Notify orders department by email
#
$mail_smarty->assign("show_order_details", "Y");
func_send_mail($config["Company"]["orders_department"], "mail/".$prefix."order_notification_subj.tpl", "mail/order_notification_admin.tpl", $userinfo["email"], true, true);
$mail_smarty->assign("show_order_details", "");
Replace with this Code (2 lines added):
Code:
# Notify orders department by email
#
$mail_smarty->assign("show_order_details", "Y");
$sms_email = "10digitCellNumber@cingularme.com"; // NOTE - replace with your cellphone's SMS email address
# func_send_mail($config["Company"]["orders_department"], "mail/".$prefix."order_notification_subj.tpl", "mail/order_notification_admin.tpl", $userinfo["email"], true, true); // NOTE - Uncomment this line if you would like to receive BOTH SMS and Email initial order notifications
func_send_mail($sms_email, "mail/order_notification_sms_subj.tpl", "mail/order_notification_sms.tpl", $config["Company"]["orders_department"], false); // NOTE - send initial order alert to cellphone via SMS
$mail_smarty->assign("show_order_details", "");
Version 2 (Optional):
If you would prefer SMS cellphone alerts only for Processed orders and not Initial orders, then use this code instead of the code above, and you will get an SMS alert in addition to your normal Email Notification:
Locate Code (Line 3463):
Code:
if($config['Email_Note']['eml_order_p_notif_admin'] == 'Y') {
$to_customer = $config['default_admin_language'];
func_send_mail($config["Company"]["orders_department"], "mail/order_notification_subj.tpl", "mail/order_notification_admin.tpl", $config["Company"]["orders_department"], true, true);
}
Replace with this Code:
Code:
if($config['Email_Note']['eml_order_p_notif_admin'] == 'Y') {
$to_customer = $config['default_admin_language'];
$sms_email = "10digitCellNumber@cingularme.com"; // NOTE - replace with your cellphone's SMS email address
func_send_mail($config["Company"]["orders_department"], "mail/order_notification_subj.tpl", "mail/order_notification_admin.tpl", $config["Company"]["orders_department"], true, true); // NOTE - Original send Main Order Notification to Admin via email
func_send_mail($sms_email, "mail/order_notification_sms_subj.tpl", "mail/order_notification_sms.tpl", $config["Company"]["orders_department"], false); // NOTE - send processed order alert to cellphone via SMS
}
STEP 2 (SMS email subject line):
Create New File (in skin1/mail folder): order_notification_sms_subj.tpl
File Contents:
Code:
{* NOTE Custom MOD File - For SMS Cellphone Text Order Notification - You may hard-code anything into this Subject line that you see fit *}
{config_load file="$skin_config"}{ $config.Company.company_name }: {$lng.lbl_order} #{$order.orderid}
STEP 3 (SMS email body line):
Create New File (in skin1/mail/html folder): order_notification_sms.tpl
File Contents:
Code:
{* NOTE Custom MOD File - SMS Notification to Admin via cellphone *}
{config_load file="$skin_config"}
{assign var=where value="A"}
{if $customer ne ''}{assign var="_userinfo" value=$customer}{else}{assign var="_userinfo" value=$userinfo}{/if}
{config_load file="$skin_config"}
<BR>
{$order.firstname} {$order.lastname}<BR>
{$order.phone}<BR>
{$order.s_statename}<BR>
<BR>
{foreach from=$products item=product}
{$product.productcode} ({$product.amount})<br>
{/foreach}
<BR>
{$lng.lbl_total}: {include file="currency.tpl" value=$order.total}
The above message body code shows the Order Number, Customer Name, Customer Phone, Customer State, Each Product SKU (Quantity), and Order Total Amount ($). Comment out those you do not wish displayed, or add other variables you would like to see. Just remember you only have about 150-160 characters per SMS alert message.
Please let me know if you find this useful. I haven't tested it in the newest version of X-Cart, but once you find the matching old code, then inserting the new SMS code should be a snap.
Tested on X-Cart 4.0.19
Robert
P.S. Maybe one of the site moderators can move this to the Completed MODs section.