<?php defined('_JEXEC') or die('=;)'); if (!empty($this->rows)) { foreach ($this->rows as $product) { echo KSSystem::loadTemplate(array('product' => $product, 'params' => $this->params)); } }
public static function sendOrderMail($order_id, $admin = false) { self::onExecuteBefore(array(&$order_id, &$admin)); $db = JFactory::getDBO(); JRequest::setVar('id', $order_id); $model = KSSystem::getModel('orders'); $order = $model->getOrder(); $order->items = KSMOrders::getOrderItems($order_id); $query = $db->getQuery(true); $query->select('*')->from('#__ksenmart_shipping_fields')->where('shipping_id=' . $order->shipping_id)->where('position=' . $db->quote('address'))->where('published=1')->order('ordering'); $db->setQuery($query); $address_fields = $db->loadObjectList(); $address = array(); foreach ($address_fields as $address_field) { if ($address_field->system && isset($order->address_fields[$address_field->title])) { $value = $order->address_fields[$address_field->title]; } elseif (!$address_field->system && isset($order->address_fields[$address_field->id])) { $value = $order->address_fields[$address_field->id]; } else { $value = ''; } $title = $address_field->system ? JText::_('ksm_cart_shipping_field_' . $address_field->title) : $address_field->title; $address[] = $title . ' - ' . $value; } $order->address_fields = implode(', ', $address); $order->customer_name = ''; if (isset($order->customer_fields['name']) && !empty($order->customer_fields['name'])) { $order->customer_name .= $order->customer_fields['name']; } if (isset($order->customer_fields['last_name']) && !empty($order->customer_fields['last_name'])) { $order->customer_name .= $order->customer_fields['last_name'] . ' '; } if (isset($order->customer_fields['first_name']) && !empty($order->customer_fields['first_name'])) { $order->customer_name .= $order->customer_fields['first_name'] . ' '; } if (isset($order->customer_fields['middle_name']) && !empty($order->customer_fields['middle_name'])) { $order->customer_name .= $order->customer_fields['middle_name']; } $order->phone = isset($order->customer_fields['phone']) && !empty($order->customer_fields['phone']) ? $order->customer_fields['phone'] : ''; $mail = JFactory::getMailer(); $params = JComponentHelper::getParams('com_ksenmart'); $sender = array($params->get('shop_email'), $params->get('shop_name')); $content = KSSystem::loadTemplate(array('order' => $order), 'order', 'default', 'mail'); $mail->isHTML(true); $mail->setSender($sender); $mail->Subject = 'Новый заказ №' . $order_id; $mail->Body = $content; if (!$admin) { $mail->AddAddress($order->customer_fields['email'], $order->customer_fields['name']); } else { $mail->AddAddress($params->get('shop_email'), $params->get('shop_name')); } $mail->Send(); self::onExecuteAfter(); return true; }
public function addComment($data) { $this->onExecuteBefore('addComment'); $user = KSUsers::getUser(); $jinput = JFactory::getApplication()->input; $params = JComponentHelper::getParams('com_ksenmart'); $comment_object = new stdClass(); $comment_object->user_id = $user->id; $comment_object->product_id = $data['product_id']; $comment_object->name = $data['comment_name']; $comment_object->comment = $data['comment_comment']; $comment_object->good = $data['comment_good']; $comment_object->bad = $data['comment_bad']; $comment_object->rate = $data['comment_rate']; if ($params->get('review_moderation', false)) { $comment_object->published = 0; } try { $result = $this->_db->insertObject('#__ksenmart_comments', $comment_object); if ($params->get('review_notice', false)) { $mail = JFactory::getMailer(); $sender = array($params->get('shop_email'), $params->get('shop_name')); $content = KSSystem::loadTemplate(array('comment' => $comment_object), 'comments', 'default', 'mail'); $mail->isHTML(true); $mail->setSender($sender); $mail->Subject = 'Новый отзыв'; $mail->Body = $content; $mail->AddAddress($params->get('shop_email'), $params->get('shop_name')); $mail->Send(); } $this->onExecuteAfter('addComment', array(&$result)); return true; } catch (Exception $e) { } }