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; }
function profile($userID = '') { // check user is logged in, if not send them away from this controller if (!$this->session->userdata('session_user')) { redirect('/users/login/' . $this->core->encode($this->uri->uri_string())); } // redirect so that the permalink is set to their ID if (!$userID) { redirect('/users/profile/' . $this->session->userdata('userID')); } // get this user data if (!($data['user'] = $this->users->get_user($userID))) { show_error('No user was found!'); } // load helper $this->load->helper('bbcode'); // show logged in user profile if ($userID == $this->session->userdata('userID')) { // set title $output['page:title'] = 'Your Profile - ' . $this->site->config['siteName']; // set view file $viewFile = 'community_home'; } else { // get user data if ($data['user'] = $this->users->get_user($userID)) { // set title $output['page:title'] = $this->site->config['siteName'] . ' | ' . $data['user']['firstName'] . '\'s Profile'; // set view file (based on privacy) if ($data['user']['privacy'] == 'H' && $data['user']['userID'] != $this->session->userdata('userID')) { $viewFile = 'community_view_profile_private'; } else { $viewFile = 'community_view_profile'; } } else { show_404(); } } $site_base_path = realpath(''); // populate template $output['user:id'] = $userID; $output['user:name'] = $data['user']['displayName'] ? $data['user']['displayName'] : $data['user']['firstName'] . ' ' . $data['user']['lastName']; $output['user:avatar'] = anchor('/users/profile/' . $data['user']['userID'], display_image($this->users->get_avatar($data['user']['avatar']), 'User Avatar', 100, 'class="bordered"', site_url() . $this->config->item('staticPath') . '/images/noavatar.gif')); $output['user:country'] = lookup_country($data['user']['country']); // load bio $data['user']['bio'] .= $userID == $this->session->userdata('userID') ? ' [[url=/users/account#changebio]Update[/url]]' : ''; $output['user:bio'] = ($data['user']['privacy'] == 'V' || $data['user']['userID'] == $this->session->userdata('userID')) && $data['user']['bio'] ? bbcode($data['user']['bio']) : FALSE; // load website $output['user:website'] = $data['user']['website'] ? $data['user']['website'] : ''; // load company $output['user:company'] = $data['user']['companyName'] ? $data['user']['companyName'] : ''; $output['user:company-website'] = $data['user']['companyWebsite'] ? $data['user']['companyWebsite'] : ''; $data['user']['companyDescription'] .= $userID == $this->session->userdata('userID') ? ' [[url=/users/account#changework]Update[/url]]' : ''; $output['user:company-description'] = ($data['user']['privacy'] == 'V' || $data['user']['userID'] == $this->session->userdata('userID')) && $data['user']['companyDescription'] ? bbcode($data['user']['companyDescription']) : FALSE; // load content $output['profile:navigation'] = $this->parser->parse('partials/profile_navigation', $data, TRUE); // set page heading $output['page:heading'] = $data['user']['firstName'] . ' ' . $data['user']['lastName'] . ($data['user']['displayName'] ? ' <small>(' . $data['user']['displayName'] . ')</small>' : ''); // display with cms layer $this->pages->view($viewFile, $output, 'community'); }
?> <br /> <?php echo $order['billingAddress1'] ? $order['billingAddress1'] . '<br />' : ''; ?> <?php echo $order['billingAddress2'] ? $order['billingAddress2'] . '<br />' : ''; ?> <?php echo $order['billingAddress3'] ? $order['billingAddress3'] . '<br />' : ''; ?> <?php echo $order['billingCity'] ? $order['billingCity'] . '<br />' : ''; ?> <?php echo $order['billingCountry'] ? lookup_country($order['billingCountry']) . '<br />' : ''; ?> <?php echo $order['billingPostcode'] ? $order['billingPostcode'] . '<br />' : ''; ?> <?php } else { ?> <small><em>Same as Shipping Address</em></small> <?php } ?> </p> </div> </div>
?> " /> <input type="hidden" name="address_city" value="<?php echo $user['city']; ?> " /> <input type="hidden" name="address_state" value="<?php echo lookup_state($user['state']); ?> " /> <input type="hidden" name="address_zip" value="<?php echo $user['postcode']; ?> " /> <input type="hidden" name="address_country" value="<?php echo lookup_country($user['country']); ?> " /> <input type="hidden" name="address_country_code" value="<?php echo $user['country']; ?> " /> <input type="hidden" name="contact_phone" value="<?php echo $user['phone']; ?> " /> <input type="hidden" name="payer_email" value="<?php echo $user['email']; ?> " />