function _create_order($orderID = '') { // get order ID $orderID = $orderID ? $orderID : $this->shop->response_data['orderID']; // get order details $orderRow = $this->shop->get_order_by_order_id($orderID); $transactionID = $orderRow['transactionID']; // get ordered products $itemOrders = $this->shop->get_item_orders($transactionID); // set header and footer $emailHeader = str_replace('{name}', trim($orderRow['firstName'] . ' ' . $orderRow['lastName']), $this->site->config['emailHeader']); $emailHeader = str_replace('{first-name}', $orderRow['firstName'], $emailHeader); $emailHeader = str_replace('{last-name}', $orderRow['lastName'], $emailHeader); $emailHeader = str_replace('{email}', $orderRow['email'], $emailHeader); $emailFooter = str_replace('{name}', trim($orderRow['firstName'] . ' ' . $orderRow['lastName']), $this->site->config['emailFooter']); $emailFooter = str_replace('{first-name}', $orderRow['firstName'], $emailFooter); $emailFooter = str_replace('{last-name}', $orderRow['lastName'], $emailFooter); $emailFooter = str_replace('{email}', $orderRow['email'], $emailFooter); $emailOrder = str_replace('{name}', trim($orderRow['firstName'] . ' ' . $orderRow['lastName']), $this->site->config['emailOrder']); $emailOrder = str_replace('{first-name}', $orderRow['firstName'], $emailOrder); $emailOrder = str_replace('{last-name}', $orderRow['lastName'], $emailOrder); $emailOrder = str_replace('{email}', $orderRow['email'], $emailOrder); // construct email to customer $userBody = $emailHeader . "\n\n"; $userBody .= $emailOrder . "\n\n"; $userBody .= "------------------------------------------\n"; // construct email to admin $adminBody = "Dear administrator,\n\n"; $adminBody .= "An order (#" . $orderID . ") has been placed on " . $this->site->config['siteName'] . ".\n\n"; $adminBody .= "------------------------------------------\n"; // grab order and make body $orderBody = "Your order:\n\n"; $orderBody .= "Reference ID #: " . $orderID . "\n\n"; // go through each order $downloadBody = ''; foreach ($itemOrders as $order) { // if stock control is enabled then minus the amount of stock if ($this->site->config['shopStockControl']) { $this->shop->minus_stock($order['productID'], $order['quantity']); } $variationHTML = ''; // get variation 1 if ($order['variation1']) { $variationHTML .= ' (' . $this->site->config['shopVariation1'] . ': ' . $order['variation1'] . ')'; } // get variations 2 if ($order['variation2']) { $variationHTML .= ' (' . $this->site->config['shopVariation2'] . ': ' . $order['variation2'] . ')'; } // get variations 3 if ($order['variation3']) { $variationHTML .= ' (' . $this->site->config['shopVariation3'] . ': ' . $order['variation3'] . ')'; } // check if its a file if ($order['fileID']) { $file = $this->shop->get_file($order['fileID']); $downloadBody .= $order['productName'] . "\n" . site_url('/files/' . $this->core->encode($file['fileRef'] . '|' . $transactionID)) . "\n\n"; } $orderBody .= $order['quantity'] . "x | #" . $order['catalogueID'] . " | " . $order['productName'] . $variationHTML . " "; $orderBody .= "| " . currency_symbol(FALSE) . number_format($order['price'] * $order['quantity'], 2) . "\n"; } // show tax if exists if ($orderRow['discounts'] > 0) { $orderBody .= "\nDiscounts: (" . currency_symbol(FALSE) . number_format($orderRow['discounts'], 2) . ")"; } // check for donations if ($orderRow['donation'] > 0) { $orderBody .= "\nDonation: " . currency_symbol(FALSE) . number_format($orderRow['donation'], 2); } // show subtotals $orderBody .= "\nSub total: " . currency_symbol(FALSE) . number_format($orderRow['amount'] - $orderRow['postage'] - $orderRow['tax'], 2); $orderBody .= "\nShipping: " . currency_symbol(FALSE) . number_format($orderRow['postage'], 2); // show tax if exists if ($orderRow['tax'] > 0) { $orderBody .= "\nTax: " . currency_symbol(FALSE) . number_format($orderRow['tax'], 2); } // show totals $orderBody .= "\nTotal: " . currency_symbol(FALSE) . number_format($orderRow['amount'], 2) . "\n\n"; $orderBody .= "------------------------------------------\n\n"; // show download links if (strlen($downloadBody) > 0) { $orderBody .= "Download Links:\n\n"; $orderBody .= $downloadBody; $orderBody .= "------------------------------------------\n\n"; } $dispatchBody = "Shipping Address:\n\n"; $dispatchBody .= $orderRow['firstName'] && $orderRow['lastName'] ? $orderRow['firstName'] . " " . $orderRow['lastName'] . "\n" : ''; $dispatchBody .= $orderRow['address1'] ? $orderRow['address1'] . "\n" : ''; $dispatchBody .= $orderRow['address2'] ? $orderRow['address2'] . "\n" : ''; $dispatchBody .= $orderRow['address3'] ? $orderRow['address3'] . "\n" : ''; $dispatchBody .= $orderRow['city'] ? $orderRow['city'] . "\n" : ''; $dispatchBody .= $orderRow['state'] ? lookup_state($orderRow['state']) . "\n" : ''; $dispatchBody .= $orderRow['postcode'] ? $orderRow['postcode'] . "\n" : ''; $dispatchBody .= $orderRow['country'] ? lookup_country($orderRow['country']) . "\n" : ''; $dispatchBody .= $orderRow['phone'] ? $orderRow['phone'] . "\n" : ''; $dispatchBody .= $orderRow['email'] . "\n"; $dispatchBody .= "------------------------------------------\n\n"; // show billing address if set if ($orderRow['billingAddress1'] || $orderRow['billingAddress2'] || $orderRow['billingCity'] || $orderRow['billingPostcode']) { $dispatchBody .= "Billing Address:\n\n"; $dispatchBody .= $orderRow['firstName'] && $orderRow['lastName'] ? $orderRow['firstName'] . " " . $orderRow['lastName'] . "\n" : ''; $dispatchBody .= $orderRow['billingAddress1'] ? $orderRow['billingAddress1'] . "\n" : ''; $dispatchBody .= $orderRow['billingAddress2'] ? $orderRow['billingAddress2'] . "\n" : ''; $dispatchBody .= $orderRow['billingAddress3'] ? $orderRow['billingAddress3'] . "\n" : ''; $dispatchBody .= $orderRow['billingCity'] ? $orderRow['billingCity'] . "\n" : ''; $dispatchBody .= $orderRow['billingState'] ? lookup_state($orderRow['billingState']) . "\n" : ''; $dispatchBody .= $orderRow['billingPostcode'] ? $orderRow['billingPostcode'] . "\n" : ''; $dispatchBody .= $orderRow['billingCountry'] ? lookup_country($orderRow['billingCountry']) . "\n" : ''; $dispatchBody .= "------------------------------------------\n\n"; } // add notes $notesBody = $orderRow['notes'] ? "Notes:\n\n" . $orderRow['notes'] . "\n\n------------------------------------------\n\n" : ''; $footerBody = $emailFooter; $this->shop->update_order($transactionID); // load email lib and email user and admin $this->load->library('email'); $this->email->to($orderRow['email']); $this->email->subject('Thank you for your order (#' . $orderID . ')'); $this->email->message($userBody . $orderBody . $dispatchBody . $notesBody . $footerBody); $this->email->from($this->site->config['siteEmail'], $this->site->config['siteName']); $this->email->send(); $this->email->clear(); $this->email->to($this->site->config['siteEmail']); $this->email->subject('Someone has placed an order (#' . $orderID . ')'); $this->email->message($adminBody . $orderBody . $dispatchBody . $notesBody . $footerBody); $this->email->from($this->site->config['siteEmail'], $this->site->config['siteName']); $this->email->send(); return TRUE; }
?> " /> <input type="hidden" name="x_ship_to_last_name" value="<?php echo $user['lastName']; ?> " /> <input type="hidden" name="x_ship_to_address" value="<?php echo $user['address1']; ?> " /> <input type="hidden" name="x_ship_to_city" value="<?php echo $user['city']; ?> " /> <input type="hidden" name="x_ship_to_state" value="<?php echo lookup_state($user['state']); ?> " /> <input type="hidden" name="x_ship_to_zip" value="<?php echo $user['postcode']; ?> " /> <input type="hidden" name="x_ship_to_country" value="<?php echo $user['country']; ?> " /> <div class="formrow ccnumber-row"> <label for="ccnumber">Card Number:</label> <input type="text" name="x_card_num" id="ccnumber" class="formelement" autocomplete="off" /> <br class="clear" />