PDA

View Full Version : nabaztag order notification



michael_s
01-29-2007, 02:12 AM
If you have a Nabaztag, you can now take advantage of the open API and osCommerce to send yourself an order announcement so the bunny will tell you when a new order has arrived.

You'll have to enable the API at http://my.nabaztag.com/vl/action/myTools.do in order to allow this to work.

The announcement message can be customized to fit your needs, but will also work perfectly "out of the box".

To install, all you need to do is place the following code after the 'SEND_EXTRA_ORDER_EMAILS_TO' if statement and before the '$payment_modules->after_process();' lines.

Here is the code...

/*
nabaztag order announcement system
*/
$nabSN = 'XXXXXXXXXXXX'; //replace with your nabaztag's serial number
$nabTK = 'XXXXXXXXXX'; //replace with your assigned API tolken number
$nabMsg = '';
$nabProdList = '';
$nabLeftEar = '1'; //modify your ear position, 1 to 16
$nabRightEar = '1'; //modify your ear position, 1 to 16

// begin announcement
$nabMsg .= 'You have a new order. Order number ' . $insert_id . ' has arrived. ';

// customer's name
$nabMsg .= $order->customer['firstname'] . ' ' . $order->customer['lastname'];

// customer's city
$nabMsg .= ' from ' . $order->customer['city'] . ' ';

// product list
for ($nabI=0, $nabN=sizeof($order->products); $nabI1) $nabProdList .= 'and ';
$nabProdList .= $order->products[$nabI]['qty'] . ' ' . $order->products[$nabI]['name'];
if ($nabI!=$nabN-1) $nabProdList .= ', ';
}
$nabMsg .= ' has ordered ' . $nabProdList . '.';

$nabAnnounce = file_get_contents('http://api.nabaztag.com/vl/FR/api.jsp?sn=' . $nabSN . '&token=' . $nabTK . '&posright=' . $nabLeftEar . '&posleft=' . $nabRightEar . '&tts=' . urlencode($nabMsg), "r");
/*
end nabaztag order announcement system
*/

More... (http://www.oscommerce.com/community/contributions,4842)