Lines 74 to 153 of the Store module. The %placeholders are replaced with !placeholders to avoid the tags /** * Implementation of hook_cron(). */ function store_cron() { /* Any item whose workflow is 'shipped', move it to 'completed'. This does seem presumptous. Ideally we'd email the user a list of shipped items for day and then adjust the shipping workflow after a given time period, such as 2 week (in case of returns or something) rather than automatically closing it here. */ db_query('UPDATE {ec_transaction} SET workflow = 6 WHERE workflow = 3 AND payment_status = 2'); if (variable_get('payment_notices', 0)) { global $base_url; // Find order(s) with a 'cleared' payment status needs action. if ($count = db_result(db_query("SELECT COUNT(st.txnid) FROM {ec_transaction} AS st WHERE st.payment_status = '2' AND (st.workflow = '1' OR st.workflow = '2' OR st.workflow = '3' OR st.workflow = '4')"))) { $beg_month = mktime(0, 0, 0, date('m'), 1, date('Y')); $mon_orders = db_result(db_query("SELECT COUNT(txnid) FROM {ec_transaction} where created >= '%d' AND payment_status = '2' AND workflow = '6'", $beg_month)); $mon_sales = '$'. number_format(db_result(db_query("SELECT SUM(gross) FROM {ec_transaction} where created >= '%d' AND payment_status = '2' AND workflow = '6'", $beg_month)), 2); $buf = t("!count order(s) with a 'cleared' payment status needs action: \n", array('!count' => $count)); $result = db_query("SELECT * FROM {ec_transaction} AS st WHERE st.payment_status = '2' AND (st.workflow = '1' OR st.workflow = '2' OR st.workflow = '3' OR st.workflow = '4') ORDER BY st.txnid DESC"); while ($data = db_fetch_object($result)) { $buf .= t('Order #!txnid created !timestamp ago', array('!txnid' => $data->txnid, '!timestamp' => format_interval(time() - $data->created, 2))). "\n"; $buf .= t('Workflow status: !transaction-workflow', array('!transaction-workflow' => transaction_get_workflow($data->workflow))). "\n"; $buf .= t('Email: !email', array('!email' => $data->mail)). "\n"; $buf .= t('Total: !gross', array('!gross' => payment_format($data->gross))). "\n"; $r = db_query("SELECT stp.*, st.payment_status, st.workflow FROM {ec_transaction} AS st, {ec_transaction_product} AS stp WHERE st.txnid = '%d' AND st.txnid = stp.txnid ORDER BY st.txnid DESC", $data->txnid); $items = NULL; $has_shippable_item = FALSE; while ($item = db_fetch_object($r)) { foreach(product_load($item) as $key => $value) { if ($key != 'title' && $key != 'price') { $item->$key = $value; } } if (product_is_shippable($item->vid)) { $has_shippable_item = TRUE; } $sku = ($item->sku) ? " [$item->sku]" : ""; $items .= t('!order of !title at !price each', array('!order' => format_plural($item->qty, '1 order', '@count orders'), '!title' => $item->title. $sku, '!price' => payment_format($item->price))); } /* If the transaction has no shippable items and the payment status is 'complete' and the workflow is 'transaction received', set the workflow to 'complete' */ if (!$has_shippable_item && $data->payment_status == 2 && $data->workflow == 1) { db_query("UPDATE {ec_transaction} SET workflow = '6' WHERE txnid = %d", $data->txnid); } $shipping_to = store_format_address($data, 'shipping', 'text'); $billing_to = store_format_address($data, 'billing', 'text'); $buf .= "Shipping to:\n$shipping_to\nBilling to:\n$billing_to\n"; $buf .= "$items"; $buf .= "\nUpdate: $base_url/admin/store/transaction/edit/$data->txnid\n"; $buf .= "=====\n"; } $output = $buf; $output .= t("(These orders will no longer be listed once the transaction workflow is set to either 'Completed' or 'Canceled')"); $output .= t("\nMonthly Summary\nNumber of completed orders: !monthly-orders\nSales: !monthly-sales\n", array('!monthly-orders' => $mon_orders, '!monthly-sales' => $mon_sales)); $output .= t("Want more reports? Visit !base_url/admin/store\n", array('!base_url' => $base_url)); $subject = t('!site-name transaction summary', array('!site-name' => variable_get('site_name', 'Drupal'))); $to = variable_get("site_mail", ini_get("sendmail_from")); $from = variable_get("site_mail", ini_get("sendmail_from")); $headers = "From: $from\nReply-to: $from\nX-Mailer: PHP\nReturn-path: $from\nErrors-to: $from"; drupal_mail('ec_order_summary', $to, $subject, $output, NULL, $headers); } } // End receive payment notices. }