1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @property Cart_model $cart_model |
5
|
|
|
* @property Customer_model $customer_model |
6
|
|
|
* @property Mail_model $mail_model |
7
|
|
|
*/ |
8
|
|
|
class Shop_model extends CI_Model { |
9
|
|
|
|
10
|
|
|
public function __construct() |
11
|
|
|
{ |
12
|
|
|
parent::__construct(); |
13
|
|
|
$this->load->model('shop/cart_model'); |
|
|
|
|
14
|
|
|
$this->load->model('shop/customer_model'); |
|
|
|
|
15
|
|
|
$this->load->model('shop/mail_model'); |
|
|
|
|
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
// 注文の処理 |
19
|
|
|
public function order() |
20
|
|
|
{ |
21
|
|
|
$data = []; |
22
|
|
|
# 注文日時をPHPのdate()関数から取得します。 |
23
|
|
|
$data['date'] = date("Y/m/d H:i:s"); |
24
|
|
|
# カートの情報を取得します。 |
25
|
|
|
$cart = $this->cart_model->get_all(); |
26
|
|
|
foreach ($cart['items'] as &$item) |
27
|
|
|
{ |
28
|
|
|
$item['price'] = number_format($item['price']); |
29
|
|
|
$item['amount'] = number_format($item['amount']); |
30
|
|
|
} |
31
|
|
|
$data['items'] = $cart['items']; |
32
|
|
|
$data['line'] = $cart['line']; |
33
|
|
|
$data['total'] = number_format($cart['total']); |
34
|
|
|
|
35
|
|
|
# お客様情報を取得します。 |
36
|
|
|
$data = array_merge($data, $this->customer_model->get()); |
37
|
|
|
|
38
|
|
|
# メールのヘッダを設定します。Bccで同じメールを管理者にも送るようにします。 |
39
|
|
|
$mail = []; |
40
|
|
|
$mail['from_name'] = 'CIショップ'; |
41
|
|
|
$mail['from'] = $this->admin; |
|
|
|
|
42
|
|
|
$mail['to'] = $data['email']; |
43
|
|
|
$mail['bcc'] = $this->admin; |
44
|
|
|
$mail['subject'] = '【注文メール】CIショップ'; |
45
|
|
|
|
46
|
|
|
# テンプレートパーサクラスでメール本文を作成します。 |
47
|
|
|
$this->load->library('parser'); |
|
|
|
|
48
|
|
|
$mail['body'] = $this->parser->parse( |
|
|
|
|
49
|
|
|
'templates/mail/shop_order', $data, TRUE |
50
|
|
|
); |
51
|
|
|
|
52
|
|
|
# sendmail()メソッドを呼び出し、実際にメールを送信します。メール送信に成功 |
53
|
|
|
# すれば、TRUEを返します。 |
54
|
|
|
if ($this->mail_model->sendmail($mail)) |
55
|
|
|
{ |
56
|
|
|
return TRUE; |
57
|
|
|
} |
58
|
|
|
# メール送信に失敗した場合は、FALSEを返します。 |
59
|
|
|
else |
60
|
|
|
{ |
61
|
|
|
return FALSE; |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
} |
66
|
|
|
|
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.