Пример #1
0
 protected static function sendSms($n, $data)
 {
     $general = wa('shop')->getConfig()->getGeneralSettings();
     /**
      * @var waContact $customer
      */
     $customer = $data['customer'];
     if ($n['to'] == 'customer') {
         $to = $customer->get('phone', 'default');
         $log = sprintf(_w("Notification <strong>%s</strong> sent to customer."), $n['name']);
     } elseif ($n['to'] == 'admin') {
         $to = $general['phone'];
         $log = sprintf(_w("Notification <strong>%s</strong> sent to store admin."), $n['name']);
     } else {
         $to = $n['to'];
         $log = sprintf(_w("Notification <strong>%s</strong> sent to %s."), $n['name'], $n['to']);
     }
     if (!$to) {
         return;
     }
     $view = wa()->getView();
     foreach (array('shipping', 'billing') as $k) {
         $address = shopHelper::getOrderAddress($data['order']['params'], $k);
         $formatter = new waContactAddressOneLineFormatter(array('image' => false));
         $address = $formatter->format(array('data' => $address));
         $view->assign($k . '_address', $address['value']);
     }
     $order_id = $data['order']['id'];
     $data['order']['id'] = shopHelper::encodeOrderId($order_id);
     $view->assign('order_url', wa()->getRouteUrl('/frontend/myOrderByCode', array('id' => $order_id, 'code' => $data['order']['params']['auth_code']), true));
     $view->assign($data);
     $text = $view->fetch('string:' . $n['text']);
     $sms = new waSMS();
     if ($sms->send($to, $text, isset($n['from']) ? $n['from'] : null)) {
         $order_log_model = new shopOrderLogModel();
         $order_log_model->add(array('order_id' => $order_id, 'contact_id' => null, 'action_id' => '', 'text' => '<i class="icon16 mobile"></i> ' . $log, 'before_state_id' => $data['order']['state_id'], 'after_state_id' => $data['order']['state_id']));
     }
 }
Пример #2
0
 public function __construct()
 {
     if (!self::$config) {
         self::$config = wa()->getConfig()->getConfigFile('sms');
     }
 }