Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function confirm($order_id, $order_status_id, $comment = '') {
- $order_query = $this->db->query("SELECT *, l.code AS language FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "language l ON (o.language_id = l.language_id) WHERE o.order_id = '" . (int)$order_id . "' AND o.order_status_id = '0'");
- if ($order_query->num_rows) {
- $language = new Language($order_query->row['language']);
- $language->load('checkout/confirm');
- $this->load->model('localisation/currency');
- $subject = sprintf($language->get('mail_new_order_subject'), html_entity_decode($this->config->get('config_store'), ENT_QUOTES, 'UTF-8'), $order_id);
- $order_status_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int)$order_status_id . "' AND language_id = '" . (int)$order_query->row['language_id'] . "'");
- $order_product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");
- $order_total_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_total WHERE order_id = '" . (int)$order_id . "' ORDER BY sort_order ASC");
- $order_download_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_download WHERE order_id = '" . (int)$order_id . "'");
- foreach ($order_product_query->rows as $product) {
- $option_data = array();
- $options = $this->getOrderOptions($order_id, $product['order_product_id']);
- foreach ($options as $option) {
- $option_data[] = array(
- 'name' => $option['name'],
- 'value' => $option['value']
- );
- }
- $orderProducts[] = array(
- 'name' => $product['name'],
- 'model' => $product['model'],
- 'option' => $option_data,
- 'quantity' => $product['quantity'],
- 'price' => $this->currency->format($product['price'], $order_query->row['currency'], $order_query->row['value']),
- 'total' => $this->currency->format($product['total'], $order_query->row['currency'], $order_query->row['value'])
- );
- }
- /**
- * HTML Order Email
- * @ Lee Turver
- */
- $htmlMessage = '<html>
- <head>
- <title>' . $this->config->get('config_store') . ' - Order Confirmation</title>
- </head>
- <body>
- <table cellspacing="0" cellpadding="0" border="0" width="98%" style="margin-top:10px; font-family: Arial, Verdana, Helvetica, sans-serif; margin-bottom:10px;">
- <tr>
- <td align="center" valign="top">
- <!-- [ header starts here] -->
- <table cellspacing="0" cellpadding="0" border="0" width="650">
- <tr>
- <td valign="top"><img src="http://demo.opencart.com/image/logo.png" alt="' . $this->config->get('config_store') . '" border="0"/></td>
- </tr>
- </table>
- <!-- [ middle starts here] -->
- <table cellspacing="0" cellpadding="0" border="0" width="650">
- <tr>
- <td valign="top">
- <p style="font-size: 10pt;">
- <strong>Hello ' . $order_query->row['firstname'] . ' ' . $order_query->row['lastname'] . '</strong>,<br/>
- ' . sprintf($language->get('mail_new_order_greeting'), html_entity_decode($this->config->get('config_store'), ENT_QUOTES, 'UTF-8')) . '
- </p>
- <p style="font-size: 10pt;">Your order confirmation is below. Thank you again for your business.</p>
- <h3 style="border-bottom:2px solid #eee; font-size:1.05em; padding-bottom:1px; ">Your Order #'. $order_id . '<small> (placed on ' . date($language->get('date_format_short'), strtotime($order_query->row['date_added'])) . ')</small></h3>
- <table cellspacing="0" cellpadding="0" border="0" width="100%">
- <thead>
- <tr>
- <th align="left" width="48.5%" bgcolor="#920400" style="font-size: 10pt; padding:5px 9px 6px 9px; color: #fff; border:1px solid #bebcb7; border-bottom:none; line-height:1em;">
- Billing Information:
- </th>
- <th width="3%"></th>
- <th align="left" width="48.5%" bgcolor="#920400" style="font-size: 10pt; padding:5px 9px 6px 9px; color: #ffffff; border:1px solid #bebcb7; border-bottom:none; line-height:1em;">
- Payment Method:
- </th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td valign="top" style="font-size: 10pt; padding:7px 9px 9px 9px; border:1px solid #bebcb7; border-top:0; background:#f8f7f5;">
- ' . $order_query->row['payment_firstname'] . ' ' . $order_query->row['payment_lastname'] . '<br />
- ' . (!empty($order_query->row['payment_company']) ? $order_query->row['payment_company'] . '<br />' : '') . '
- ' . (!empty($order_query->row['payment_address_1']) ? $order_query->row['payment_address_1'] . '<br />' : '') . '
- ' . (!empty($order_query->row['payment_address_2']) ? $order_query->row['payment_address_2'] . '<br />' : '') . '
- ' . (!empty($order_query->row['payment_city']) ? $order_query->row['payment_city'] . '<br />' : '') . '
- ' . (!empty($order_query->row['payment_postcode']) ? $order_query->row['payment_postcode'] . '<br />' : '') . '
- ' . (!empty($order_query->row['payment_zone']) ? $order_query->row['payment_zone'] . '<br />' : '') . '
- ' . (!empty($order_query->row['payment_country']) ? $order_query->row['payment_country'] : '') . '
- </td>
- <td> </td>
- <td valign="top" style="font-size: 10pt; padding:7px 9px 9px 9px; border:1px solid #bebcb7; border-top:0; background:#f8f7f5;">
- ' . $order_query->row['payment_method'] . '
- </td>
- </tr>
- </tbody>
- </table>
- <br/>
- <table cellspacing="0" cellpadding="0" border="0" width="100%">
- <thead>
- <tr>
- <th align="left" width="48.5%" bgcolor="#920400" style="font-size: 10pt; padding:5px 9px 6px 9px; color: #ffffff; border:1px solid #bebcb7; border-bottom:none; line-height:1em;">
- Shipping Information:
- </th>
- <th width="3%"></th>
- <th align="left" width="48.5%" bgcolor="#920400" style="font-size: 10pt; padding:5px 9px 6px 9px; color: #ffffff; border:1px solid #bebcb7; border-bottom:none; line-height:1em;">
- Shipping Method:
- </th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td valign="top" style="font-size: 10pt; padding:7px 9px 9px 9px; border:1px solid #bebcb7; border-top:0; background:#f8f7f5;">
- ' . $order_query->row['shipping_firstname'] . ' ' . $order_query->row['shipping_lastname'] . '<br />
- ' . (!empty($order_query->row['shipping_company']) ? $order_query->row['shipping_company'] . '<br />' : '') . '
- ' . (!empty($order_query->row['shipping_address_1']) ? $order_query->row['shipping_address_1'] . '<br />' : '') . '
- ' . (!empty($order_query->row['shipping_address_2']) ? $order_query->row['shipping_address_2'] . '<br />' : '') . '
- ' . (!empty($order_query->row['shipping_city']) ? $order_query->row['shipping_city'] . '<br />' : '') . '
- ' . (!empty($order_query->row['shipping_postcode']) ? $order_query->row['shipping_postcode'] . '<br />' : '') . '
- ' . (!empty($order_query->row['shipping_zone']) ? $order_query->row['shipping_zone'] . '<br />' : '') . '
- ' . (!empty($order_query->row['shipping_country']) ? $order_query->row['shipping_country'] : '') . '
- </td>
- <td> </td>
- <td valign="top" style="font-size: 10pt; padding:7px 9px 9px 9px; border:1px solid #bebcb7; border-top:0; background:#f8f7f5;">
- ' . $order_query->row['shipping_method'] . '
- </td>
- </tr>
- </tbody>
- </table>
- <br/>
- <table cellspacing="0" cellpadding="0" border="0" width="100%" style="border:1px solid #bebcb7; background:#f8f7f5;">
- <thead>
- <tr>
- <th align="left" bgcolor="#920400" style="color: #ffffff; font-size: 10pt; padding:3px 9px">Item</th>
- <th align="center" bgcolor="#920400" style="color: #ffffff; font-size: 10pt; padding:3px 9px">Qty</th>
- <th align="center" bgcolor="#920400" style="color: #ffffff; font-size: 10pt; padding:3px 9px">Unit Price</th>
- <th align="right" bgcolor="#920400" style="color: #ffffff; font-size: 10pt; padding:3px 9px">Subtotal</th>
- </tr>
- </thead>
- <tbody bgcolor="#eeeded">';
- foreach($orderProducts as $product):
- $htmlMessage .= '
- <tr>
- <td align="left" valign="top" style="padding:3px 9px; font-size: 10pt; ">
- <strong>' . $product['name'] . '</strong>';
- foreach ($product['option'] as $option):
- $htmlMessage .= '<br /> <small> - '. $option['name'] . ' ' . $option['value'] . '</small>';
- endforeach;
- $htmlMessage .= '
- </td>
- <td align="center" valign="top" style="padding:3px 9px; font-size: 10pt;">' . $product['quantity'] . '</td>
- <td align="center" valign="top" style="padding:3px 9px; font-size: 10pt;">' . $product['price'] . '</td>
- <td align="right" valign="top" style="padding:3px 9px; font-size: 10pt; ">' . $product['total'] . '</td>
- </tr>';
- endforeach;
- $htmlMessage .= '
- </tbody>
- <tfoot>';
- foreach ($order_total_query->rows as $result):
- if($result['title'] != 'Total:'):
- $htmlMessage .= '
- <tr>
- <td colspan="3" align="right" style="padding:3px 9px; font-size: 10pt;">' . $result['title'] . '</td>
- <td align="right" style="padding:3px 9px; font-size: 10pt;"><span class="price">' . $result['text'] . '</span></td>
- </tr>';
- else:
- $htmlMessage .= '
- <tr bgcolor="#DEE5E8">
- <td colspan="3" align="right" style="padding:3px 9px; font-size: 10pt;"><strong><big>' . $result['title'] . '</big></strong></td>
- <td align="right" style="padding:6px 9px; font-size: 10pt;"><strong><big><span class="price">' . $result['text'] . '</span></big></strong></td>
- </tr>';
- endif;
- endforeach;
- $htmlMessage .= '
- </tfoot>
- </table>
- <br/>
- <p>Thank you again,<br/><strong>' . $this->config->get('config_store') . '</strong></p>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- </body>
- </html>';
- /**
- * HTML Order Text End
- * Begin Plain Text Message
- */
- // Text Mail
- $message = sprintf($language->get('mail_new_order_greeting'), html_entity_decode($this->config->get('config_store'), ENT_QUOTES, 'UTF-8')) . "\n\n";
- $message .= $language->get('mail_new_order_order') . ' ' . $order_id . "\n";
- $message .= $language->get('mail_new_order_date_added') . ' ' . date($language->get('date_format_short'), strtotime($order_query->row['date_added'])) . "\n";
- $message .= $language->get('mail_new_order_order_status') . ' ' . $order_status_query->row['name'] . "\n\n";
- $message .= $language->get('mail_new_order_product') . "\n";
- foreach ($order_product_query->rows as $result) {
- $message .= $result['quantity'] . 'x ' . $result['name'] . ' (' . $result['model'] . ') ' . html_entity_decode($this->currency->format($result['total'], $order_query->row['currency'], $order_query->row['value']), ENT_NOQUOTES, 'UTF-8') . "\n";
- }
- $message .= "\n";
- $message .= $language->get('mail_new_order_total') . "\n";
- foreach ($order_total_query->rows as $result) {
- $message .= $result['title'] . ' ' . html_entity_decode($result['text'], ENT_NOQUOTES, 'UTF-8') . "\n";
- }
- $message .= "\n";
- $message .= $language->get('mail_new_order_invoice') . "\n";
- $message .= html_entity_decode($this->url->http('account/invoice&order_id=' . $order_id), ENT_QUOTES, 'UTF-8') . "\n\n";
- if ($order_download_query->num_rows) {
- $message .= $language->get('mail_new_order_download') . "\n";
- $message .= $this->url->http('account/download') . "\n\n";
- }
- if ($comment) {
- $message .= $language->get('mail_new_order_comment') . "\n\n";
- $message .= $comment . "\n\n";
- }
- $message .= $language->get('mail_new_order_footer');
- $mail = new Mail($this->config->get('config_mail_protocol'), $this->config->get('config_smtp_host'), $this->config->get('config_smtp_username'), html_entity_decode($this->config->get('config_smtp_password'), ENT_QUOTES, 'UTF-8'), $this->config->get('config_smtp_port'), $this->config->get('config_smtp_timeout'));
- $mail->setTo($order_query->row['email']);
- $mail->setFrom($this->config->get('config_email'));
- $mail->setSender(html_entity_decode($this->config->get('config_store'), ENT_QUOTES, 'UTF-8'));
- $mail->setSubject($subject);
- $mail->setHtml($htmlMessage);
- $mail->setText($message);
- $mail->send();
- if ($this->config->get('config_alert_mail')) {
- $mail = new Mail($this->config->get('config_mail_protocol'), $this->config->get('config_smtp_host'), $this->config->get('config_smtp_username'), $this->config->get('config_smtp_password'), $this->config->get('config_smtp_port'), $this->config->get('config_smtp_timeout'));
- $mail->setTo($this->config->get('config_email'));
- $mail->setFrom($this->config->get('config_email'));
- $mail->setSender(html_entity_decode($this->config->get('config_store'), ENT_QUOTES, 'UTF-8'));
- $mail->setSubject($subject);
- $mail->setHtml($htmlMessage);
- $mail->setText($message);
- $mail->send();
- }
- if ($this->config->get('config_stock_subtract')) {
- $order_product_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");
- foreach ($order_product_query->rows as $product) {
- $this->db->query("UPDATE " . DB_PREFIX . "product SET quantity = (quantity - " . (int)$product['quantity'] . ") WHERE product_id = '" . (int)$product['product_id'] . "'");
- $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int)$order_id . "' AND order_product_id = '" . (int)$product['order_product_id'] . "'");
- foreach ($order_option_query->rows as $option) {
- $this->db->query("UPDATE " . DB_PREFIX . "product_option_value SET quantity = (quantity - " . (int)$product['quantity'] . ") WHERE product_option_value_id = '" . (int)$option['product_option_value_id'] . "' AND subtract = '1'");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement