1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of EC-CUBE |
4
|
|
|
* |
5
|
|
|
* Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved. |
6
|
|
|
* |
7
|
|
|
* http://www.lockon.co.jp/ |
8
|
|
|
* |
9
|
|
|
* This program is free software; you can redistribute it and/or |
10
|
|
|
* modify it under the terms of the GNU General Public License |
11
|
|
|
* as published by the Free Software Foundation; either version 2 |
12
|
|
|
* of the License, or (at your option) any later version. |
13
|
|
|
* |
14
|
|
|
* This program is distributed in the hope that it will be useful, |
15
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17
|
|
|
* GNU General Public License for more details. |
18
|
|
|
* |
19
|
|
|
* You should have received a copy of the GNU General Public License |
20
|
|
|
* along with this program; if not, write to the Free Software |
21
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
namespace Eccube\Controller; |
26
|
|
|
|
27
|
|
|
use Eccube\Application; |
28
|
|
|
use Eccube\Common\Constant; |
29
|
|
|
use Eccube\Entity\Customer; |
30
|
|
|
use Eccube\Entity\CustomerAddress; |
31
|
|
|
use Eccube\Entity\MailHistory; |
32
|
|
|
use Eccube\Entity\ShipmentItem; |
33
|
|
|
use Eccube\Entity\Shipping; |
34
|
|
|
use Eccube\Event\EccubeEvents; |
35
|
|
|
use Eccube\Event\EventArgs; |
36
|
|
|
use Eccube\Exception\CartException; |
37
|
|
|
use Symfony\Component\HttpFoundation\Request; |
38
|
|
|
use Symfony\Component\HttpFoundation\Response; |
39
|
|
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
40
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
41
|
|
|
|
42
|
|
|
class ShoppingController extends AbstractController |
|
|
|
|
43
|
|
|
{ |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @var string 非会員用セッションキー |
47
|
|
|
*/ |
48
|
|
|
private $sessionKey = 'eccube.front.shopping.nonmember'; |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @var string 非会員用セッションキー |
52
|
|
|
*/ |
53
|
|
|
private $sessionCustomerAddressKey = 'eccube.front.shopping.nonmember.customeraddress'; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @var string 複数配送警告メッセージ |
57
|
|
|
*/ |
58
|
|
|
private $sessionMultipleKey = 'eccube.front.shopping.multiple'; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @var string 受注IDキー |
62
|
|
|
*/ |
63
|
|
|
private $sessionOrderKey = 'eccube.front.shopping.order.id'; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* 購入画面表示 |
67
|
|
|
* |
68
|
|
|
* @param Application $app |
69
|
|
|
* @param Request $request |
|
|
|
|
70
|
20 |
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse|Response |
71
|
|
|
*/ |
72
|
|
|
public function index(Application $app, Request $request) |
73
|
|
|
{ |
74
|
|
|
$cartService = $app['eccube.service.cart']; |
75
|
|
|
|
76
|
|
|
// カートチェック |
77
|
|
|
if (!$cartService->isLocked()) { |
78
|
|
|
// カートが存在しない、カートがロックされていない時はエラー |
79
|
|
|
return $app->redirect($app->url('cart')); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
// カートチェック |
83
|
|
|
if (count($cartService->getCart()->getCartItems()) <= 0) { |
84
|
|
|
// カートが存在しない時はエラー |
85
|
|
|
return $app->redirect($app->url('cart')); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
// 登録済みの受注情報を取得 |
89
|
|
|
$Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); |
90
|
|
|
|
91
|
|
|
// 初回アクセス(受注情報がない)の場合は, 受注情報を作成 |
92
|
|
|
if (is_null($Order)) { |
93
|
|
|
// 未ログインの場合, ログイン画面へリダイレクト. |
94
|
|
|
if (!$app->isGranted('IS_AUTHENTICATED_FULLY')) { |
95
|
|
|
// 非会員でも一度会員登録されていればショッピング画面へ遷移 |
96
|
|
|
$Customer = $app['eccube.service.shopping']->getNonMember($this->sessionKey); |
97
|
|
|
|
98
|
|
|
if (is_null($Customer)) { |
99
|
|
|
return $app->redirect($app->url('shopping_login')); |
100
|
|
|
} |
101
|
8 |
|
} else { |
102
|
|
|
$Customer = $app->user(); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
try { |
106
|
|
|
// 受注情報を作成 |
107
|
|
|
$Order = $app['eccube.service.shopping']->createOrder($Customer); |
108
|
|
|
} catch (CartException $e) { |
109
|
17 |
|
$app->addRequestError($e->getMessage()); |
110
|
|
|
|
111
|
|
|
return $app->redirect($app->url('cart')); |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
// セッション情報を削除 |
115
|
|
|
$app['session']->remove($this->sessionOrderKey); |
116
|
|
|
$app['session']->remove($this->sessionMultipleKey); |
117
|
17 |
|
} else { |
118
|
|
|
// 計算処理 |
119
|
|
|
$Order = $app['eccube.service.shopping']->getAmount($Order); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
// 受注関連情報を最新状態に更新 |
123
|
|
|
$app['orm.em']->refresh($Order); |
124
|
|
|
|
125
|
|
|
// form作成 |
126
|
|
|
$builder = $app['eccube.service.shopping']->getShippingFormBuilder($Order); |
127
|
|
|
|
128
|
|
|
$event = new EventArgs( |
129
|
|
|
array( |
130
|
|
|
'builder' => $builder, |
131
|
|
|
'Order' => $Order, |
132
|
|
|
), |
133
|
17 |
|
$request |
134
|
17 |
|
); |
135
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_INDEX_INITIALIZE, $event); |
136
|
|
|
|
137
|
20 |
|
$form = $builder->getForm(); |
138
|
|
|
|
139
|
|
|
// 複数配送の場合、エラーメッセージを一度だけ表示 |
140
|
|
|
if (!$app['session']->has($this->sessionMultipleKey)) { |
141
|
|
|
if (count($Order->getShippings()) > 1) { |
142
|
4 |
|
$app->addRequestError('shopping.multiple.delivery'); |
143
|
|
|
} |
144
|
|
|
$app['session']->set($this->sessionMultipleKey, 'multiple'); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
return $app->render( |
148
|
|
|
'Shopping/index.twig', |
149
|
|
|
array( |
150
|
|
|
'form' => $form->createView(), |
151
|
|
|
'Order' => $Order, |
152
|
|
|
) |
153
|
4 |
|
); |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
/** |
|
|
|
|
157
|
|
|
* 購入処理 |
158
|
|
|
*/ |
|
|
|
|
159
|
|
|
public function confirm(Application $app, Request $request) |
160
|
|
|
{ |
161
|
|
|
$cartService = $app['eccube.service.cart']; |
162
|
|
|
|
163
|
|
|
// カートチェック |
164
|
|
|
if (!$cartService->isLocked()) { |
165
|
|
|
// カートが存在しない、カートがロックされていない時はエラー |
166
|
|
|
return $app->redirect($app->url('cart')); |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
$Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); |
170
|
|
|
if (!$Order) { |
171
|
|
|
$app->addError('front.shopping.order.error'); |
172
|
|
|
|
173
|
|
|
return $app->redirect($app->url('shopping_error')); |
174
|
|
|
} |
175
|
4 |
|
|
176
|
|
|
if ('POST' !== $request->getMethod()) { |
177
|
|
|
return $app->redirect($app->url('cart')); |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
// form作成 |
181
|
|
|
$builder = $app['eccube.service.shopping']->getShippingFormBuilder($Order); |
182
|
|
|
|
183
|
|
|
$event = new EventArgs( |
184
|
|
|
array( |
185
|
|
|
'builder' => $builder, |
186
|
|
|
'Order' => $Order, |
187
|
|
|
), |
188
|
|
|
$request |
189
|
|
|
); |
190
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_CONFIRM_INITIALIZE, $event); |
191
|
|
|
|
192
|
|
|
$form = $builder->getForm(); |
193
|
|
|
|
194
|
|
|
$form->handleRequest($request); |
195
|
|
|
|
196
|
|
|
if ($form->isSubmitted() && $form->isValid()) { |
197
|
|
|
$data = $form->getData(); |
198
|
|
|
|
199
|
|
|
// トランザクション制御 |
200
|
|
|
$em = $app['orm.em']; |
201
|
|
|
$em->getConnection()->beginTransaction(); |
202
|
4 |
|
try { |
203
|
|
|
// 商品公開ステータスチェック、商品制限数チェック、在庫チェック |
204
|
|
|
$check = $app['eccube.service.shopping']->isOrderProduct($em, $Order); |
205
|
|
|
if (!$check) { |
206
|
|
|
$em->getConnection()->rollback(); |
207
|
|
|
|
208
|
|
|
$app->addError('front.shopping.stock.error'); |
209
|
|
|
|
210
|
|
|
return $app->redirect($app->url('shopping_error')); |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
// 受注情報、配送情報を更新 |
214
|
|
|
$app['eccube.service.shopping']->setOrderUpdate($Order, $data); |
215
|
|
|
// 在庫情報を更新 |
216
|
4 |
|
$app['eccube.service.shopping']->setStockUpdate($em, $Order); |
217
|
4 |
|
|
218
|
4 |
|
if ($app->isGranted('ROLE_USER')) { |
219
|
|
|
// 会員の場合、購入金額を更新 |
220
|
|
|
$app['eccube.service.shopping']->setCustomerUpdate($Order, $app->user()); |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
$em->flush(); |
224
|
|
|
$em->getConnection()->commit(); |
225
|
4 |
|
|
|
|
|
|
226
|
4 |
|
} catch (\Exception $e) { |
227
|
|
|
$em->getConnection()->rollback(); |
228
|
|
|
|
229
|
|
|
$app->log($e); |
230
|
|
|
|
231
|
|
|
$app->addError('front.shopping.system.error'); |
232
|
|
|
|
233
|
|
|
return $app->redirect($app->url('shopping_error')); |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
// カート削除 |
237
|
|
|
$app['eccube.service.cart']->clear()->save(); |
238
|
|
|
|
239
|
|
|
$event = new EventArgs( |
240
|
|
|
array( |
241
|
4 |
|
'form' => $form, |
242
|
|
|
'Order' => $Order, |
243
|
|
|
), |
244
|
|
|
$request |
245
|
|
|
); |
246
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_CONFIRM_PROCESSING, $event); |
247
|
1 |
|
|
248
|
|
|
if ($event->getResponse() !== null) { |
249
|
|
|
return $event->getResponse(); |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
// メール送信 |
253
|
|
|
$app['eccube.service.mail']->sendOrderMail($Order); |
254
|
|
|
|
255
|
1 |
|
// 受注IDをセッションにセット |
256
|
|
|
$app['session']->set($this->sessionOrderKey, $Order->getId()); |
257
|
|
|
|
258
|
1 |
|
// 送信履歴を保存. |
259
|
|
|
$MailTemplate = $app['eccube.repository.mail_template']->find(1); |
260
|
|
|
|
261
|
|
|
$body = $app->renderView( |
262
|
|
|
$MailTemplate->getFileName(), |
263
|
|
|
array( |
264
|
3 |
|
'header' => $MailTemplate->getHeader(), |
265
|
|
|
'footer' => $MailTemplate->getFooter(), |
266
|
|
|
'Order' => $Order, |
267
|
|
|
) |
268
|
|
|
); |
269
|
|
|
|
270
|
|
|
$MailHistory = new MailHistory(); |
271
|
|
|
$MailHistory |
272
|
|
|
->setSubject( |
273
|
3 |
|
'['.$app['eccube.repository.base_info']->get()->getShopName().'] '.$MailTemplate->getSubject() |
274
|
|
|
) |
275
|
|
|
->setMailBody($body) |
276
|
|
|
->setMailTemplate($MailTemplate) |
277
|
|
|
->setSendDate(new \DateTime()) |
278
|
|
|
->setOrder($Order); |
279
|
|
|
$app['orm.em']->persist($MailHistory); |
280
|
|
|
$app['orm.em']->flush($MailHistory); |
281
|
|
|
|
282
|
|
|
$event = new EventArgs( |
283
|
|
|
array( |
284
|
|
|
'form' => $form, |
285
|
|
|
'Order' => $Order, |
286
|
|
|
'MailHistory' => $MailHistory, |
287
|
|
|
), |
288
|
1 |
|
$request |
289
|
|
|
); |
290
|
1 |
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_CONFIRM_COMPLETE, $event); |
291
|
|
|
|
292
|
|
|
if ($event->getResponse() !== null) { |
293
|
|
|
return $event->getResponse(); |
294
|
|
|
} |
295
|
|
|
|
296
|
1 |
|
// 完了画面表示 |
297
|
|
|
return $app->redirect($app->url('shopping_complete')); |
298
|
|
|
} |
299
|
1 |
|
|
300
|
|
|
return $app->render( |
301
|
|
|
'Shopping/index.twig', |
302
|
|
|
array( |
303
|
|
|
'form' => $form->createView(), |
304
|
|
|
'Order' => $Order, |
305
|
|
|
) |
306
|
|
|
); |
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
|
310
|
|
|
/** |
|
|
|
|
311
|
|
|
* 購入完了画面表示 |
312
|
|
|
*/ |
|
|
|
|
313
|
|
|
public function complete(Application $app, Request $request) |
314
|
1 |
|
{ |
315
|
1 |
|
// 受注IDを取得 |
316
|
|
|
$orderId = $app['session']->get($this->sessionOrderKey); |
317
|
|
|
|
318
|
|
|
$event = new EventArgs( |
319
|
|
|
array( |
320
|
|
|
'orderId' => $orderId, |
321
|
|
|
), |
322
|
|
|
$request |
323
|
|
|
); |
324
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_COMPLETE_INITIALIZE, $event); |
325
|
|
|
|
326
|
|
|
if ($event->getResponse() !== null) { |
327
|
|
|
return $event->getResponse(); |
328
|
|
|
} |
329
|
|
|
|
330
|
|
|
// 受注IDセッションを削除 |
331
|
|
|
$app['session']->remove($this->sessionOrderKey); |
332
|
|
|
|
333
|
|
|
return $app->render( |
334
|
|
|
'Shopping/complete.twig', |
335
|
2 |
|
array( |
336
|
2 |
|
'orderId' => $orderId, |
337
|
|
|
) |
338
|
|
|
); |
339
|
3 |
|
} |
340
|
|
|
|
341
|
|
|
|
342
|
|
|
/** |
|
|
|
|
343
|
|
|
* 配送業者選択処理 |
344
|
2 |
|
*/ |
|
|
|
|
345
|
|
|
public function delivery(Application $app, Request $request) |
346
|
|
|
{ |
347
|
2 |
|
// カートチェック |
348
|
|
|
if (!$app['eccube.service.cart']->isLocked()) { |
349
|
|
|
// カートが存在しない、カートがロックされていない時はエラー |
350
|
|
|
return $app->redirect($app->url('cart')); |
351
|
|
|
} |
352
|
|
|
|
353
|
|
|
$Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); |
354
|
|
|
if (!$Order) { |
355
|
|
|
$app->addError('front.shopping.order.error'); |
356
|
|
|
|
357
|
|
|
return $app->redirect($app->url('shopping_error')); |
358
|
|
|
} |
359
|
|
|
|
360
|
|
|
if ('POST' !== $request->getMethod()) { |
361
|
1 |
|
return $app->redirect($app->url('shopping')); |
362
|
1 |
|
} |
363
|
|
|
|
364
|
|
|
$builder = $app['eccube.service.shopping']->getShippingFormBuilder($Order); |
365
|
|
|
|
366
|
|
|
$event = new EventArgs( |
367
|
|
|
array( |
368
|
|
|
'builder' => $builder, |
369
|
|
|
'Order' => $Order, |
370
|
|
|
), |
371
|
|
|
$request |
372
|
|
|
); |
373
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_DELIVERY_INITIALIZE, $event); |
374
|
|
|
|
375
|
|
|
$form = $builder->getForm(); |
376
|
|
|
|
377
|
|
|
$form->handleRequest($request); |
378
|
|
|
|
379
|
|
|
if ($form->isSubmitted() && $form->isValid()) { |
380
|
1 |
|
$data = $form->getData(); |
381
|
1 |
|
|
382
|
|
|
$shippings = $data['shippings']; |
383
|
|
|
|
384
|
2 |
|
$productDeliveryFeeTotal = 0; |
385
|
|
|
$BaseInfo = $app['eccube.repository.base_info']->get(); |
386
|
|
|
|
387
|
|
|
foreach ($shippings as $Shipping) { |
388
|
|
|
$Delivery = $Shipping->getDelivery(); |
389
|
3 |
|
|
390
|
|
|
if ($Delivery) { |
391
|
|
|
$deliveryFee = $app['eccube.repository.delivery_fee']->findOneBy( |
392
|
3 |
|
array( |
393
|
|
|
'Delivery' => $Delivery, |
394
|
|
|
'Pref' => $Shipping->getPref(), |
395
|
|
|
) |
396
|
|
|
); |
397
|
|
|
|
398
|
|
|
// 商品ごとの配送料合計 |
399
|
|
|
if (!is_null($BaseInfo->getOptionProductDeliveryFee())) { |
400
|
|
|
$productDeliveryFeeTotal += $app['eccube.service.shopping']->getProductDeliveryFee($Shipping); |
401
|
|
|
} |
402
|
|
|
|
403
|
|
|
$Shipping->setDeliveryFee($deliveryFee); |
404
|
|
|
$Shipping->setShippingDeliveryFee($deliveryFee->getFee() + $productDeliveryFeeTotal); |
405
|
|
|
$Shipping->setShippingDeliveryName($Delivery->getName()); |
406
|
3 |
|
} |
407
|
|
|
} |
408
|
|
|
|
409
|
|
|
// 支払い情報をセット |
410
|
|
|
$payment = $data['payment']; |
411
|
|
|
$message = $data['message']; |
412
|
|
|
|
413
|
|
|
$Order->setPayment($payment); |
414
|
|
|
$Order->setPaymentMethod($payment->getMethod()); |
415
|
|
|
$Order->setMessage($message); |
416
|
|
|
$Order->setCharge($payment->getCharge()); |
417
|
|
|
|
418
|
|
|
$Order->setDeliveryFeeTotal($app['eccube.service.shopping']->getShippingDeliveryFeeTotal($shippings)); |
419
|
3 |
|
|
420
|
|
|
$total = $Order->getSubTotal() + $Order->getCharge() + $Order->getDeliveryFeeTotal(); |
421
|
|
|
|
422
|
|
|
$Order->setTotal($total); |
423
|
|
|
$Order->setPaymentTotal($total); |
424
|
2 |
|
|
425
|
|
|
// 受注関連情報を最新状態に更新 |
426
|
|
|
$app['orm.em']->flush(); |
427
|
|
|
|
428
|
|
|
$event = new EventArgs( |
429
|
|
|
array( |
430
|
|
|
'form' => $form, |
431
|
|
|
'Order' => $Order, |
432
|
|
|
), |
433
|
|
|
$request |
434
|
|
|
); |
435
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_DELIVERY_COMPLETE, $event); |
436
|
|
|
|
437
|
|
|
return $app->redirect($app->url('shopping')); |
438
|
|
|
} |
439
|
|
|
|
440
|
|
|
return $app->render( |
441
|
|
|
'Shopping/index.twig', |
442
|
|
|
array( |
443
|
|
|
'form' => $form->createView(), |
444
|
|
|
'Order' => $Order, |
445
|
|
|
) |
446
|
|
|
); |
447
|
|
|
} |
448
|
|
|
|
449
|
|
|
/** |
|
|
|
|
450
|
|
|
* 支払い方法選択処理 |
451
|
|
|
*/ |
|
|
|
|
452
|
|
|
public function payment(Application $app, Request $request) |
453
|
|
|
{ |
454
|
|
|
$Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); |
455
|
|
|
if (!$Order) { |
456
|
|
|
$app->addError('front.shopping.order.error'); |
457
|
|
|
|
458
|
|
|
return $app->redirect($app->url('shopping_error')); |
459
|
|
|
} |
460
|
|
|
|
461
|
|
|
if ('POST' !== $request->getMethod()) { |
462
|
|
|
return $app->redirect($app->url('shopping')); |
463
|
|
|
} |
464
|
|
|
|
465
|
|
|
$builder = $app['eccube.service.shopping']->getShippingFormBuilder($Order); |
466
|
|
|
|
467
|
|
|
$event = new EventArgs( |
468
|
|
|
array( |
469
|
|
|
'builder' => $builder, |
470
|
|
|
'Order' => $Order, |
471
|
|
|
), |
472
|
|
|
$request |
473
|
|
|
); |
474
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_PAYMENT_INITIALIZE, $event); |
475
|
|
|
|
476
|
|
|
$form = $builder->getForm(); |
477
|
|
|
|
478
|
|
|
$form->handleRequest($request); |
479
|
|
|
|
480
|
|
|
if ($form->isSubmitted() && $form->isValid()) { |
481
|
|
|
$data = $form->getData(); |
482
|
2 |
|
$payment = $data['payment']; |
483
|
|
|
$message = $data['message']; |
484
|
2 |
|
|
485
|
|
|
$Order->setPayment($payment); |
486
|
2 |
|
$Order->setPaymentMethod($payment->getMethod()); |
487
|
|
|
$Order->setMessage($message); |
488
|
|
|
$Order->setCharge($payment->getCharge()); |
489
|
2 |
|
|
490
|
|
|
$total = $Order->getSubTotal() + $Order->getCharge() + $Order->getDeliveryFeeTotal(); |
491
|
|
|
|
492
|
|
|
$Order->setTotal($total); |
493
|
|
|
$Order->setPaymentTotal($total); |
494
|
5 |
|
|
495
|
|
|
// 受注関連情報を最新状態に更新 |
496
|
|
|
$app['orm.em']->flush(); |
497
|
5 |
|
|
498
|
|
|
$event = new EventArgs( |
499
|
|
|
array( |
500
|
|
|
'form' => $form, |
501
|
|
|
'Order' => $Order, |
502
|
|
|
), |
503
|
|
|
$request |
504
|
|
|
); |
505
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_PAYMENT_COMPLETE, $event); |
506
|
|
|
|
507
|
|
|
return $app->redirect($app->url('shopping')); |
508
|
|
|
} |
509
|
|
|
|
510
|
|
|
return $app->render( |
511
|
3 |
|
'Shopping/index.twig', |
512
|
|
|
array( |
513
|
|
|
'form' => $form->createView(), |
514
|
|
|
'Order' => $Order, |
515
|
|
|
) |
516
|
|
|
); |
517
|
|
|
} |
518
|
|
|
|
519
|
|
|
/** |
|
|
|
|
520
|
1 |
|
* お届け先変更がクリックされた場合の処理 |
521
|
1 |
|
*/ |
|
|
|
|
522
|
|
View Code Duplication |
public function shippingChange(Application $app, Request $request, $id) |
|
|
|
|
523
|
|
|
{ |
524
|
5 |
|
$Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); |
525
|
|
|
if (!$Order) { |
526
|
|
|
$app->addError('front.shopping.order.error'); |
527
|
|
|
|
528
|
|
|
return $app->redirect($app->url('shopping_error')); |
529
|
2 |
|
} |
530
|
|
|
|
531
|
|
|
if ('POST' !== $request->getMethod()) { |
532
|
|
|
return $app->redirect($app->url('shopping')); |
533
|
|
|
} |
534
|
|
|
|
535
|
|
|
$builder = $app['eccube.service.shopping']->getShippingFormBuilder($Order); |
536
|
|
|
|
537
|
|
|
$event = new EventArgs( |
538
|
|
|
array( |
539
|
|
|
'builder' => $builder, |
540
|
|
|
'Order' => $Order, |
541
|
|
|
), |
542
|
|
|
$request |
543
|
|
|
); |
544
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_INDEX_INITIALIZE, $event); |
545
|
|
|
|
546
|
|
|
$form = $builder->getForm(); |
547
|
|
|
|
548
|
2 |
|
$form->handleRequest($request); |
549
|
|
|
|
550
|
|
|
if ($form->isSubmitted() && $form->isValid()) { |
551
|
|
|
$data = $form->getData(); |
552
|
|
|
$message = $data['message']; |
553
|
|
|
$Order->setMessage($message); |
554
|
2 |
|
// 受注情報を更新 |
555
|
|
|
$app['orm.em']->flush(); |
556
|
|
|
|
557
|
|
|
// お届け先設定一覧へリダイレクト |
558
|
|
|
return $app->redirect($app->url('shopping_shipping', array('id' => $id))); |
559
|
|
|
} |
560
|
|
|
|
561
|
|
|
return $app->render( |
562
|
|
|
'Shopping/index.twig', |
563
|
|
|
array( |
564
|
|
|
'form' => $form->createView(), |
565
|
|
|
'Order' => $Order, |
566
|
|
|
) |
567
|
|
|
); |
568
|
|
|
} |
569
|
|
|
|
570
|
|
|
/** |
|
|
|
|
571
|
|
|
* お届け先の設定一覧からの選択 |
572
|
|
|
*/ |
|
|
|
|
573
|
|
|
public function shipping(Application $app, Request $request, $id) |
574
|
|
|
{ |
575
|
|
|
// カートチェック |
576
|
2 |
|
if (!$app['eccube.service.cart']->isLocked()) { |
577
|
|
|
// カートが存在しない、カートがロックされていない時はエラー |
578
|
|
|
return $app->redirect($app->url('cart')); |
579
|
|
|
} |
580
|
|
|
|
581
|
|
|
if ('POST' === $request->getMethod()) { |
582
|
|
|
$address = $request->get('address'); |
583
|
|
|
|
584
|
|
|
if (is_null($address)) { |
585
|
|
|
// 選択されていなければエラー |
586
|
|
|
return $app->render( |
587
|
|
|
'Shopping/shipping.twig', |
588
|
|
|
array( |
589
|
2 |
|
'Customer' => $app->user(), |
590
|
2 |
|
'shippingId' => $id, |
591
|
|
|
'error' => true, |
592
|
|
|
) |
593
|
2 |
|
); |
594
|
|
|
} |
595
|
|
|
|
596
|
|
|
// 選択されたお届け先情報を取得 |
597
|
|
|
$CustomerAddress = $app['eccube.repository.customer_address']->findOneBy( |
598
|
|
|
array( |
599
|
|
|
'Customer' => $app->user(), |
600
|
|
|
'id' => $address, |
601
|
|
|
) |
602
|
|
|
); |
603
|
|
|
if (is_null($CustomerAddress)) { |
604
|
|
|
throw new NotFoundHttpException(); |
605
|
|
|
} |
606
|
|
|
|
607
|
|
|
$Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); |
608
|
|
|
if (!$Order) { |
609
|
|
|
$app->addError('front.shopping.order.error'); |
610
|
|
|
|
611
|
|
|
return $app->redirect($app->url('shopping_error')); |
612
|
|
|
} |
613
|
|
|
|
614
|
|
|
$Shipping = $Order->findShipping($id); |
615
|
|
|
if (!$Shipping) { |
616
|
|
|
throw new NotFoundHttpException(); |
617
|
|
|
} |
618
|
|
|
|
619
|
|
|
// お届け先情報を更新 |
620
|
|
|
$Shipping |
621
|
|
|
->setFromCustomerAddress($CustomerAddress); |
622
|
|
|
|
623
|
|
|
// 配送料金の設定 |
624
|
|
|
$app['eccube.service.shopping']->setShippingDeliveryFee($Shipping); |
625
|
|
|
|
626
|
|
|
// 配送先を更新 |
627
|
|
|
$app['orm.em']->flush(); |
628
|
|
|
|
629
|
|
|
$event = new EventArgs( |
630
|
|
|
array( |
631
|
|
|
'Order' => $Order, |
632
|
|
|
'shippingId' => $id, |
633
|
|
|
), |
634
|
|
|
$request |
635
|
|
|
); |
636
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_SHIPPING_COMPLETE, $event); |
637
|
|
|
|
638
|
|
|
return $app->redirect($app->url('shopping')); |
639
|
|
|
} |
640
|
|
|
|
641
|
|
|
return $app->render( |
642
|
|
|
'Shopping/shipping.twig', |
643
|
|
|
array( |
644
|
|
|
'Customer' => $app->user(), |
645
|
|
|
'shippingId' => $id, |
646
|
|
|
'error' => false, |
647
|
|
|
) |
648
|
|
|
); |
649
|
|
|
} |
650
|
|
|
|
651
|
|
|
/** |
|
|
|
|
652
|
|
|
* お届け先の設定(非会員)がクリックされた場合の処理 |
653
|
|
|
*/ |
|
|
|
|
654
|
|
View Code Duplication |
public function shippingEditChange(Application $app, Request $request, $id) |
|
|
|
|
655
|
|
|
{ |
656
|
|
|
$Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); |
657
|
|
|
if (!$Order) { |
658
|
|
|
$app->addError('front.shopping.order.error'); |
659
|
|
|
|
660
|
|
|
return $app->redirect($app->url('shopping_error')); |
661
|
|
|
} |
662
|
|
|
|
663
|
|
|
if ('POST' !== $request->getMethod()) { |
664
|
|
|
return $app->redirect($app->url('shopping')); |
665
|
2 |
|
} |
666
|
|
|
|
667
|
|
|
$builder = $app['eccube.service.shopping']->getShippingFormBuilder($Order); |
668
|
|
|
|
669
|
|
|
$event = new EventArgs( |
670
|
|
|
array( |
671
|
|
|
'builder' => $builder, |
672
|
|
|
'Order' => $Order, |
673
|
|
|
), |
674
|
|
|
$request |
675
|
|
|
); |
676
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_INDEX_INITIALIZE, $event); |
677
|
|
|
|
678
|
|
|
$form = $builder->getForm(); |
679
|
|
|
|
680
|
|
|
$form->handleRequest($request); |
681
|
|
|
|
682
|
|
|
if ($form->isSubmitted() && $form->isValid()) { |
683
|
|
|
$data = $form->getData(); |
684
|
|
|
$message = $data['message']; |
685
|
|
|
$Order->setMessage($message); |
686
|
|
|
// 受注情報を更新 |
687
|
|
|
$app['orm.em']->flush(); |
688
|
|
|
|
689
|
|
|
// お届け先設定一覧へリダイレクト |
690
|
|
|
return $app->redirect($app->url('shopping_shipping_edit', array('id' => $id))); |
691
|
2 |
|
} |
692
|
|
|
|
693
|
|
|
return $app->render( |
694
|
|
|
'Shopping/index.twig', |
695
|
|
|
array( |
696
|
12 |
|
'form' => $form->createView(), |
697
|
|
|
'Order' => $Order, |
698
|
|
|
) |
699
|
|
|
); |
700
|
|
|
} |
701
|
|
|
|
702
|
|
|
/** |
|
|
|
|
703
|
|
|
* お届け先の設定(非会員でも使用する) |
704
|
|
|
*/ |
|
|
|
|
705
|
|
|
public function shippingEdit(Application $app, Request $request, $id) |
706
|
|
|
{ |
707
|
|
|
//check is member or not and set header title |
708
|
|
|
if ($app->isGranted('IS_AUTHENTICATED_FULLY')) { |
709
|
|
|
//is member |
710
|
|
|
$title = "お届け先の追加"; |
711
|
|
|
} else { |
712
|
|
|
//non member |
713
|
|
|
$title = "お届け先の変更"; |
714
|
|
|
} |
715
|
|
|
// 配送先住所最大値判定 |
716
|
|
|
$Customer = $app->user(); |
717
|
|
View Code Duplication |
if ($app->isGranted('IS_AUTHENTICATED_FULLY')) { |
|
|
|
|
718
|
|
|
$addressCurrNum = count($app->user()->getCustomerAddresses()); |
719
|
|
|
$addressMax = $app['config']['deliv_addr_max']; |
720
|
|
|
if ($addressCurrNum >= $addressMax) { |
721
|
|
|
throw new NotFoundHttpException(); |
722
|
|
|
} |
723
|
|
|
} |
724
|
9 |
|
|
725
|
9 |
|
// カートチェック |
726
|
9 |
|
if (!$app['eccube.service.cart']->isLocked()) { |
727
|
9 |
|
// カートが存在しない、カートがロックされていない時はエラー |
728
|
9 |
|
return $app->redirect($app->url('cart')); |
729
|
9 |
|
} |
730
|
9 |
|
|
731
|
9 |
|
$Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); |
732
|
9 |
|
if (!$Order) { |
733
|
9 |
|
$app->addError('front.shopping.order.error'); |
734
|
9 |
|
|
735
|
9 |
|
return $app->redirect($app->url('shopping_error')); |
736
|
9 |
|
} |
737
|
9 |
|
|
738
|
|
|
$Shipping = $Order->findShipping($id); |
739
|
|
|
if (!$Shipping) { |
740
|
|
|
throw new NotFoundHttpException(); |
741
|
|
|
} |
742
|
|
|
if ($app->isGranted('IS_AUTHENTICATED_FULLY')) { |
743
|
9 |
|
$Shipping->clearCustomerAddress(); |
744
|
9 |
|
} |
745
|
9 |
|
|
746
|
9 |
|
$CustomerAddress = new CustomerAddress(); |
747
|
9 |
|
if ($app->isGranted('IS_AUTHENTICATED_FULLY')) { |
748
|
9 |
|
$CustomerAddress->setCustomer($Customer); |
749
|
9 |
|
} else { |
750
|
9 |
|
$CustomerAddress->setFromShipping($Shipping); |
751
|
9 |
|
} |
752
|
9 |
|
|
753
|
9 |
|
$builder = $app['form.factory']->createBuilder('shopping_shipping', $CustomerAddress); |
754
|
9 |
|
|
755
|
9 |
|
$event = new EventArgs( |
756
|
9 |
|
array( |
757
|
9 |
|
'builder' => $builder, |
758
|
|
|
'Order' => $Order, |
759
|
|
|
'Shipping' => $Shipping, |
760
|
|
|
'CustomerAddress' => $CustomerAddress, |
761
|
|
|
), |
762
|
|
|
$request |
763
|
|
|
); |
764
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_SHIPPING_EDIT_INITIALIZE, $event); |
765
|
|
|
|
766
|
|
|
$form = $builder->getForm(); |
767
|
|
|
|
768
|
|
|
$form->handleRequest($request); |
769
|
|
|
|
770
|
|
View Code Duplication |
if ($form->isSubmitted() && $form->isValid()) { |
|
|
|
|
771
|
|
|
// 会員の場合、お届け先情報を新規登録 |
772
|
|
|
$Shipping->setFromCustomerAddress($CustomerAddress); |
773
|
9 |
|
|
774
|
|
|
if ($Customer instanceof Customer) { |
|
|
|
|
775
|
|
|
$app['orm.em']->persist($CustomerAddress); |
776
|
|
|
} |
777
|
9 |
|
|
778
|
9 |
|
// 配送料金の設定 |
779
|
|
|
$app['eccube.service.shopping']->setShippingDeliveryFee($Shipping); |
780
|
|
|
|
781
|
|
|
// 配送先を更新 |
782
|
9 |
|
$app['orm.em']->flush(); |
783
|
9 |
|
|
784
|
|
|
$event = new EventArgs( |
785
|
|
|
array( |
786
|
|
|
'form' => $form, |
787
|
|
|
'Shipping' => $Shipping, |
788
|
|
|
'CustomerAddress' => $CustomerAddress, |
789
|
1 |
|
), |
790
|
1 |
|
$request |
791
|
|
|
); |
792
|
12 |
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_SHIPPING_EDIT_COMPLETE, $event); |
793
|
|
|
|
794
|
|
|
return $app->redirect($app->url('shopping')); |
795
|
|
|
} |
796
|
|
|
|
797
|
|
|
return $app->render( |
798
|
|
|
'Shopping/shipping_edit.twig', |
799
|
|
|
array( |
800
|
|
|
'form' => $form->createView(), |
801
|
|
|
'shippingId' => $id, |
802
|
|
|
'title' => $title, |
803
|
|
|
) |
804
|
|
|
); |
805
|
|
|
} |
806
|
|
|
|
807
|
|
|
/** |
|
|
|
|
808
|
|
|
* お客様情報の変更(非会員) |
809
|
|
|
*/ |
|
|
|
|
810
|
|
|
public function customer(Application $app, Request $request) |
811
|
|
|
{ |
812
|
|
|
if ($request->isXmlHttpRequest()) { |
813
|
|
|
try { |
814
|
|
|
$data = $request->request->all(); |
815
|
|
|
|
816
|
|
|
// 入力チェック |
817
|
|
|
$errors = $this->customerValidation($app, $data); |
818
|
|
|
|
819
|
|
|
foreach ($errors as $error) { |
820
|
|
View Code Duplication |
if ($error->count() != 0) { |
|
|
|
|
821
|
|
|
$response = new Response(json_encode('NG'), 400); |
822
|
|
|
$response->headers->set('Content-Type', 'application/json'); |
823
|
|
|
|
824
|
|
|
return $response; |
825
|
|
|
} |
826
|
|
|
} |
827
|
|
|
|
828
|
|
|
$pref = $app['eccube.repository.master.pref']->findOneBy(array('name' => $data['customer_pref'])); |
829
|
|
View Code Duplication |
if (!$pref) { |
|
|
|
|
830
|
|
|
$response = new Response(json_encode('NG'), 400); |
831
|
|
|
$response->headers->set('Content-Type', 'application/json'); |
832
|
|
|
|
833
|
|
|
return $response; |
834
|
|
|
} |
835
|
|
|
|
836
|
|
|
$Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); |
837
|
|
|
if (!$Order) { |
838
|
|
|
$app->addError('front.shopping.order.error'); |
839
|
|
|
|
840
|
|
|
return $app->redirect($app->url('shopping_error')); |
841
|
|
|
} |
842
|
|
|
|
843
|
|
|
$Order |
844
|
|
|
->setName01($data['customer_name01']) |
845
|
|
|
->setName02($data['customer_name02']) |
846
|
|
|
->setCompanyName($data['customer_company_name']) |
847
|
|
|
->setTel01($data['customer_tel01']) |
848
|
|
|
->setTel02($data['customer_tel02']) |
849
|
|
|
->setTel03($data['customer_tel03']) |
850
|
|
|
->setZip01($data['customer_zip01']) |
851
|
|
|
->setZip02($data['customer_zip02']) |
852
|
|
|
->setZipCode($data['customer_zip01'].$data['customer_zip02']) |
853
|
|
|
->setPref($pref) |
854
|
|
|
->setAddr01($data['customer_addr01']) |
855
|
|
|
->setAddr02($data['customer_addr02']) |
856
|
|
|
->setEmail($data['customer_email']); |
857
|
|
|
|
858
|
|
|
// 配送先を更新 |
859
|
|
|
$app['orm.em']->flush(); |
860
|
|
|
|
861
|
|
|
// 受注関連情報を最新状態に更新 |
862
|
|
|
$app['orm.em']->refresh($Order); |
863
|
|
|
|
864
|
|
|
$event = new EventArgs( |
865
|
|
|
array( |
866
|
|
|
'Order' => $Order, |
867
|
|
|
'data' => $data, |
868
|
|
|
), |
869
|
|
|
$request |
870
|
|
|
); |
871
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_CUSTOMER_INITIALIZE, $event); |
872
|
|
|
|
873
|
|
|
$response = new Response(json_encode('OK')); |
874
|
|
|
$response->headers->set('Content-Type', 'application/json'); |
875
|
|
|
} catch (\Exception $e) { |
876
|
|
|
$app['monolog']->error($e); |
877
|
|
|
|
878
|
|
|
$response = new Response(json_encode('NG'), 500); |
879
|
|
|
$response->headers->set('Content-Type', 'application/json'); |
880
|
|
|
} |
881
|
|
|
|
882
|
|
|
return $response; |
883
|
|
|
} |
884
|
|
|
} |
885
|
|
|
|
886
|
|
|
/** |
|
|
|
|
887
|
|
|
* ログイン |
888
|
|
|
*/ |
|
|
|
|
889
|
|
|
public function login(Application $app, Request $request) |
890
|
|
|
{ |
891
|
|
|
if (!$app['eccube.service.cart']->isLocked()) { |
892
|
|
|
return $app->redirect($app->url('cart')); |
893
|
|
|
} |
894
|
|
|
|
895
|
|
|
if ($app->isGranted('IS_AUTHENTICATED_FULLY')) { |
896
|
|
|
return $app->redirect($app->url('shopping')); |
897
|
|
|
} |
898
|
|
|
|
899
|
|
|
/* @var $form \Symfony\Component\Form\FormInterface */ |
900
|
|
|
$builder = $app['form.factory']->createNamedBuilder('', 'customer_login'); |
901
|
|
|
|
902
|
|
View Code Duplication |
if ($app->isGranted('IS_AUTHENTICATED_REMEMBERED')) { |
|
|
|
|
903
|
|
|
$Customer = $app->user(); |
904
|
|
|
if ($Customer) { |
905
|
|
|
$builder->get('login_email')->setData($Customer->getEmail()); |
906
|
|
|
} |
907
|
|
|
} |
908
|
|
|
|
909
|
|
|
$event = new EventArgs( |
910
|
|
|
array( |
911
|
|
|
'builder' => $builder, |
912
|
|
|
), |
913
|
|
|
$request |
914
|
|
|
); |
915
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_LOGIN_INITIALIZE, $event); |
916
|
|
|
|
917
|
|
|
$form = $builder->getForm(); |
918
|
|
|
|
919
|
|
|
return $app->render( |
920
|
|
|
'Shopping/login.twig', |
921
|
|
|
array( |
922
|
|
|
'error' => $app['security.last_error']($request), |
923
|
|
|
'form' => $form->createView(), |
924
|
|
|
) |
925
|
|
|
); |
926
|
|
|
} |
927
|
|
|
|
928
|
|
|
/** |
|
|
|
|
929
|
|
|
* 非会員処理 |
930
|
|
|
*/ |
|
|
|
|
931
|
|
|
public function nonmember(Application $app, Request $request) |
932
|
|
|
{ |
933
|
|
|
$cartService = $app['eccube.service.cart']; |
934
|
|
|
|
935
|
|
|
// カートチェック |
936
|
|
|
if (!$cartService->isLocked()) { |
937
|
|
|
// カートが存在しない、カートがロックされていない時はエラー |
938
|
|
|
return $app->redirect($app->url('cart')); |
939
|
|
|
} |
940
|
|
|
|
941
|
|
|
// ログイン済みの場合は, 購入画面へリダイレクト. |
942
|
|
|
if ($app->isGranted('ROLE_USER')) { |
943
|
|
|
return $app->redirect($app->url('shopping')); |
944
|
|
|
} |
945
|
|
|
|
946
|
|
|
// カートチェック |
947
|
|
|
if (count($cartService->getCart()->getCartItems()) <= 0) { |
948
|
|
|
// カートが存在しない時はエラー |
949
|
|
|
return $app->redirect($app->url('cart')); |
950
|
|
|
} |
951
|
|
|
|
952
|
|
|
$builder = $app['form.factory']->createBuilder('nonmember'); |
953
|
|
|
|
954
|
|
|
$event = new EventArgs( |
955
|
|
|
array( |
956
|
|
|
'builder' => $builder, |
957
|
|
|
), |
958
|
|
|
$request |
959
|
|
|
); |
960
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_NONMEMBER_INITIALIZE, $event); |
961
|
|
|
|
962
|
|
|
$form = $builder->getForm(); |
963
|
|
|
|
964
|
|
|
$form->handleRequest($request); |
965
|
|
|
|
966
|
|
|
if ($form->isSubmitted() && $form->isValid()) { |
967
|
|
|
$data = $form->getData(); |
968
|
|
|
$Customer = new Customer(); |
969
|
|
|
$Customer |
970
|
|
|
->setName01($data['name01']) |
971
|
|
|
->setName02($data['name02']) |
972
|
|
|
->setKana01($data['kana01']) |
973
|
|
|
->setKana02($data['kana02']) |
974
|
|
|
->setCompanyName($data['company_name']) |
975
|
|
|
->setEmail($data['email']) |
976
|
|
|
->setTel01($data['tel01']) |
977
|
|
|
->setTel02($data['tel02']) |
978
|
|
|
->setTel03($data['tel03']) |
979
|
|
|
->setZip01($data['zip01']) |
980
|
|
|
->setZip02($data['zip02']) |
981
|
|
|
->setZipCode($data['zip01'].$data['zip02']) |
982
|
|
|
->setPref($data['pref']) |
983
|
|
|
->setAddr01($data['addr01']) |
984
|
|
|
->setAddr02($data['addr02']); |
985
|
|
|
|
986
|
|
|
// 非会員複数配送用 |
987
|
|
|
$CustomerAddress = new CustomerAddress(); |
988
|
|
|
$CustomerAddress |
989
|
|
|
->setCustomer($Customer) |
990
|
|
|
->setName01($data['name01']) |
991
|
|
|
->setName02($data['name02']) |
992
|
|
|
->setKana01($data['kana01']) |
993
|
|
|
->setKana02($data['kana02']) |
994
|
|
|
->setCompanyName($data['company_name']) |
995
|
|
|
->setTel01($data['tel01']) |
996
|
|
|
->setTel02($data['tel02']) |
997
|
|
|
->setTel03($data['tel03']) |
998
|
|
|
->setZip01($data['zip01']) |
999
|
|
|
->setZip02($data['zip02']) |
1000
|
|
|
->setZipCode($data['zip01'].$data['zip02']) |
1001
|
|
|
->setPref($data['pref']) |
1002
|
|
|
->setAddr01($data['addr01']) |
1003
|
|
|
->setAddr02($data['addr02']) |
1004
|
|
|
->setDelFlg(Constant::DISABLED); |
1005
|
|
|
$Customer->addCustomerAddress($CustomerAddress); |
1006
|
|
|
|
1007
|
|
|
// 受注情報を取得 |
1008
|
|
|
$Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); |
1009
|
|
|
|
1010
|
|
|
// 初回アクセス(受注データがない)の場合は, 受注情報を作成 |
1011
|
|
|
if (is_null($Order)) { |
1012
|
|
|
// 受注情報を作成 |
1013
|
|
|
try { |
1014
|
|
|
// 受注情報を作成 |
1015
|
|
|
$app['eccube.service.shopping']->createOrder($Customer); |
1016
|
|
|
} catch (CartException $e) { |
1017
|
|
|
$app->addRequestError($e->getMessage()); |
1018
|
|
|
|
1019
|
|
|
return $app->redirect($app->url('cart')); |
1020
|
|
|
} |
1021
|
|
|
} |
1022
|
|
|
|
1023
|
|
|
// 非会員用セッションを作成 |
1024
|
|
|
$nonMember = array(); |
1025
|
|
|
$nonMember['customer'] = $Customer; |
1026
|
|
|
$nonMember['pref'] = $Customer->getPref()->getId(); |
1027
|
|
|
$app['session']->set($this->sessionKey, $nonMember); |
1028
|
|
|
|
1029
|
|
|
$customerAddresses = array(); |
1030
|
|
|
$customerAddresses[] = $CustomerAddress; |
1031
|
|
|
$app['session']->set($this->sessionCustomerAddressKey, serialize($customerAddresses)); |
1032
|
|
|
|
1033
|
|
|
$event = new EventArgs( |
1034
|
|
|
array( |
1035
|
|
|
'form' => $form, |
1036
|
|
|
'Order' => $Order, |
1037
|
|
|
), |
1038
|
|
|
$request |
1039
|
|
|
); |
1040
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_NONMEMBER_COMPLETE, $event); |
1041
|
|
|
|
1042
|
|
|
if ($event->getResponse() !== null) { |
1043
|
|
|
return $event->getResponse(); |
1044
|
|
|
} |
1045
|
|
|
|
1046
|
|
|
return $app->redirect($app->url('shopping')); |
1047
|
|
|
} |
1048
|
|
|
|
1049
|
|
|
return $app->render( |
1050
|
1 |
|
'Shopping/nonmember.twig', |
1051
|
|
|
array( |
1052
|
|
|
'form' => $form->createView(), |
1053
|
1 |
|
) |
1054
|
|
|
); |
1055
|
|
|
} |
1056
|
|
|
|
1057
|
|
|
/** |
|
|
|
|
1058
|
|
|
* 複数配送処理がクリックされた場合の処理 |
1059
|
|
|
*/ |
|
|
|
|
1060
|
|
View Code Duplication |
public function shippingMultipleChange(Application $app, Request $request) |
|
|
|
|
1061
|
|
|
{ |
1062
|
|
|
$Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); |
1063
|
|
|
if (!$Order) { |
1064
|
|
|
$app->addError('front.shopping.order.error'); |
1065
|
|
|
|
1066
|
|
|
return $app->redirect($app->url('shopping_error')); |
1067
|
|
|
} |
1068
|
|
|
|
1069
|
|
|
if ('POST' !== $request->getMethod()) { |
1070
|
|
|
return $app->redirect($app->url('shopping')); |
1071
|
|
|
} |
1072
|
|
|
|
1073
|
|
|
$builder = $app['eccube.service.shopping']->getShippingFormBuilder($Order); |
1074
|
|
|
|
1075
|
|
|
$event = new EventArgs( |
1076
|
|
|
array( |
1077
|
|
|
'builder' => $builder, |
1078
|
|
|
'Order' => $Order, |
1079
|
|
|
), |
1080
|
|
|
$request |
1081
|
|
|
); |
1082
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_INDEX_INITIALIZE, $event); |
1083
|
|
|
|
1084
|
|
|
$form = $builder->getForm(); |
1085
|
|
|
|
1086
|
|
|
$form->handleRequest($request); |
1087
|
|
|
|
1088
|
|
|
if ($form->isSubmitted() && $form->isValid()) { |
1089
|
|
|
$data = $form->getData(); |
1090
|
|
|
$message = $data['message']; |
1091
|
|
|
$Order->setMessage($message); |
1092
|
|
|
// 受注情報を更新 |
1093
|
|
|
$app['orm.em']->flush(); |
1094
|
|
|
|
1095
|
|
|
// 複数配送設定へリダイレクト |
1096
|
|
|
return $app->redirect($app->url('shopping_shipping_multiple')); |
1097
|
|
|
} |
1098
|
|
|
|
1099
|
|
|
return $app->render( |
1100
|
|
|
'Shopping/index.twig', |
1101
|
|
|
array( |
1102
|
|
|
'form' => $form->createView(), |
1103
|
|
|
'Order' => $Order, |
1104
|
|
|
) |
1105
|
|
|
); |
1106
|
|
|
} |
1107
|
|
|
|
1108
|
|
|
|
1109
|
|
|
/** |
|
|
|
|
1110
|
|
|
* 複数配送処理 |
1111
|
|
|
*/ |
|
|
|
|
1112
|
|
|
public function shippingMultiple(Application $app, Request $request) |
1113
|
|
|
{ |
1114
|
|
|
$cartService = $app['eccube.service.cart']; |
1115
|
|
|
|
1116
|
|
|
// カートチェック |
1117
|
|
|
if (!$cartService->isLocked()) { |
1118
|
|
|
// カートが存在しない、カートがロックされていない時はエラー |
1119
|
|
|
return $app->redirect($app->url('cart')); |
1120
|
|
|
} |
1121
|
|
|
|
1122
|
|
|
// カートチェック |
1123
|
|
|
if (count($cartService->getCart()->getCartItems()) <= 0) { |
1124
|
|
|
// カートが存在しない時はエラー |
1125
|
|
|
return $app->redirect($app->url('cart')); |
1126
|
|
|
} |
1127
|
|
|
$Order = $app['eccube.service.shopping']->getOrder($app['config']['order_processing']); |
1128
|
|
|
if (!$Order) { |
1129
|
|
|
$app->addError('front.shopping.order.error'); |
1130
|
|
|
|
1131
|
|
|
return $app->redirect($app->url('shopping_error')); |
1132
|
|
|
} |
1133
|
|
|
|
1134
|
|
|
// 複数配送時は商品毎でお届け先を設定する為、商品をまとめた数量を設定 |
1135
|
|
|
$compItemQuantities = array(); |
1136
|
|
View Code Duplication |
foreach ($Order->getShippings() as $Shipping) { |
|
|
|
|
1137
|
|
|
foreach ($Shipping->getShipmentItems() as $ShipmentItem) { |
1138
|
|
|
$itemId = $ShipmentItem->getProductClass()->getId(); |
1139
|
|
|
$quantity = $ShipmentItem->getQuantity(); |
1140
|
|
|
if (array_key_exists($itemId, $compItemQuantities)) { |
1141
|
|
|
$compItemQuantities[$itemId] = $compItemQuantities[$itemId] + $quantity; |
1142
|
|
|
} else { |
1143
|
|
|
$compItemQuantities[$itemId] = $quantity; |
1144
|
|
|
} |
1145
|
|
|
} |
1146
|
|
|
} |
1147
|
|
|
|
1148
|
|
|
// 商品に紐づく商品情報を取得 |
1149
|
|
|
$shipmentItems = array(); |
1150
|
|
|
$productClassIds = array(); |
1151
|
|
|
foreach ($Order->getShippings() as $Shipping) { |
1152
|
|
|
foreach ($Shipping->getShipmentItems() as $ShipmentItem) { |
1153
|
|
|
if (!in_array($ShipmentItem->getProductClass()->getId(), $productClassIds)) { |
1154
|
|
|
$shipmentItems[] = $ShipmentItem; |
1155
|
|
|
} |
1156
|
|
|
$productClassIds[] = $ShipmentItem->getProductClass()->getId(); |
1157
|
|
|
} |
1158
|
|
|
} |
1159
|
|
|
|
1160
|
|
|
$builder = $app->form(); |
1161
|
|
|
$builder |
1162
|
|
|
->add( |
1163
|
|
|
'shipping_multiple', |
1164
|
|
|
'collection', |
1165
|
|
|
array( |
1166
|
|
|
'type' => 'shipping_multiple', |
1167
|
|
|
'data' => $shipmentItems, |
1168
|
|
|
'allow_add' => true, |
1169
|
|
|
'allow_delete' => true, |
1170
|
|
|
) |
1171
|
|
|
); |
1172
|
|
|
|
1173
|
|
|
$event = new EventArgs( |
1174
|
|
|
array( |
1175
|
|
|
'builder' => $builder, |
1176
|
|
|
'Order' => $Order, |
1177
|
|
|
), |
1178
|
|
|
$request |
1179
|
|
|
); |
1180
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_SHIPPING_MULTIPLE_INITIALIZE, $event); |
1181
|
|
|
|
1182
|
|
|
$form = $builder->getForm(); |
1183
|
|
|
|
1184
|
|
|
$form->handleRequest($request); |
1185
|
|
|
|
1186
|
|
|
$errors = array(); |
1187
|
|
|
if ($form->isSubmitted() && $form->isValid()) { |
1188
|
|
|
$data = $form['shipping_multiple']; |
1189
|
|
|
|
1190
|
|
|
// 数量が超えていないか、同一でないとエラー |
1191
|
|
|
$itemQuantities = array(); |
1192
|
|
|
foreach ($data as $mulitples) { |
1193
|
|
|
/** @var \Eccube\Entity\ShipmentItem $multipleItem */ |
1194
|
|
|
$multipleItem = $mulitples->getData(); |
1195
|
|
View Code Duplication |
foreach ($mulitples as $items) { |
|
|
|
|
1196
|
|
|
foreach ($items as $item) { |
1197
|
|
|
$quantity = $item['quantity']->getData(); |
1198
|
|
|
$itemId = $multipleItem->getProductClass()->getId(); |
1199
|
|
|
if (array_key_exists($itemId, $itemQuantities)) { |
1200
|
|
|
$itemQuantities[$itemId] = $itemQuantities[$itemId] + $quantity; |
1201
|
|
|
} else { |
1202
|
|
|
$itemQuantities[$itemId] = $quantity; |
1203
|
|
|
} |
1204
|
|
|
} |
1205
|
|
|
} |
1206
|
|
|
} |
1207
|
|
|
|
1208
|
|
|
foreach ($compItemQuantities as $key => $value) { |
1209
|
|
|
if (array_key_exists($key, $itemQuantities)) { |
1210
|
|
|
if ($itemQuantities[$key] != $value) { |
1211
|
|
|
$errors[] = array('message' => '数量の数が異なっています。'); |
1212
|
|
|
|
1213
|
|
|
// 対象がなければエラー |
1214
|
|
|
return $app->render( |
1215
|
|
|
'Shopping/shipping_multiple.twig', |
1216
|
|
|
array( |
1217
|
|
|
'form' => $form->createView(), |
1218
|
|
|
'shipmentItems' => $shipmentItems, |
1219
|
|
|
'compItemQuantities' => $compItemQuantities, |
1220
|
|
|
'errors' => $errors, |
1221
|
|
|
) |
1222
|
|
|
); |
1223
|
|
|
} |
1224
|
|
|
} |
1225
|
|
|
} |
1226
|
|
|
|
1227
|
|
|
// お届け先情報をdelete/insert |
1228
|
|
|
$shippings = $Order->getShippings(); |
1229
|
|
|
foreach ($shippings as $Shipping) { |
1230
|
|
|
$Order->removeShipping($Shipping); |
1231
|
|
|
$app['orm.em']->remove($Shipping); |
1232
|
|
|
} |
1233
|
|
|
|
1234
|
|
|
foreach ($data as $mulitples) { |
1235
|
|
|
/** @var \Eccube\Entity\ShipmentItem $multipleItem */ |
1236
|
|
|
$multipleItem = $mulitples->getData(); |
1237
|
|
|
|
1238
|
|
|
foreach ($mulitples as $items) { |
1239
|
|
|
foreach ($items as $item) { |
1240
|
|
|
// 追加された配送先情報を作成 |
1241
|
|
|
$Delivery = $multipleItem->getShipping()->getDelivery(); |
1242
|
|
|
|
1243
|
|
|
// 選択された情報を取得 |
1244
|
|
|
$data = $item['customer_address']->getData(); |
1245
|
|
|
if ($data instanceof CustomerAddress) { |
|
|
|
|
1246
|
|
|
// 会員の場合、CustomerAddressオブジェクトを取得 |
1247
|
|
|
$CustomerAddress = $data; |
1248
|
|
|
} else { |
1249
|
|
|
// 非会員の場合、選択されたindexが取得される |
1250
|
|
|
$customerAddresses = $app['session']->get($this->sessionCustomerAddressKey); |
1251
|
|
|
$customerAddresses = unserialize($customerAddresses); |
1252
|
|
|
$CustomerAddress = $customerAddresses[$data]; |
1253
|
|
|
$pref = $app['eccube.repository.master.pref']->find($CustomerAddress->getPref()->getId()); |
1254
|
|
|
$CustomerAddress->setPref($pref); |
1255
|
|
|
} |
1256
|
|
|
|
1257
|
|
|
$Shipping = new Shipping(); |
1258
|
|
|
$Shipping |
1259
|
|
|
->setFromCustomerAddress($CustomerAddress) |
1260
|
|
|
->setDelivery($Delivery) |
1261
|
|
|
->setDelFlg(Constant::DISABLED) |
1262
|
|
|
->setOrder($Order); |
1263
|
|
|
$app['orm.em']->persist($Shipping); |
1264
|
|
|
|
1265
|
|
|
$ProductClass = $multipleItem->getProductClass(); |
1266
|
|
|
$Product = $multipleItem->getProduct(); |
1267
|
|
|
$quantity = $item['quantity']->getData(); |
1268
|
|
|
|
1269
|
|
|
$ShipmentItem = new ShipmentItem(); |
1270
|
|
|
$ShipmentItem->setShipping($Shipping) |
1271
|
|
|
->setOrder($Order) |
1272
|
|
|
->setProductClass($ProductClass) |
1273
|
|
|
->setProduct($Product) |
1274
|
|
|
->setProductName($Product->getName()) |
1275
|
|
|
->setProductCode($ProductClass->getCode()) |
1276
|
|
|
->setPrice($ProductClass->getPrice02()) |
1277
|
|
|
->setQuantity($quantity); |
1278
|
|
|
|
1279
|
|
|
$ClassCategory1 = $ProductClass->getClassCategory1(); |
1280
|
|
|
if (!is_null($ClassCategory1)) { |
1281
|
|
|
$ShipmentItem->setClasscategoryName1($ClassCategory1->getName()); |
1282
|
|
|
$ShipmentItem->setClassName1($ClassCategory1->getClassName()->getName()); |
1283
|
|
|
} |
1284
|
|
|
$ClassCategory2 = $ProductClass->getClassCategory2(); |
1285
|
|
|
if (!is_null($ClassCategory2)) { |
1286
|
|
|
$ShipmentItem->setClasscategoryName2($ClassCategory2->getName()); |
1287
|
|
|
$ShipmentItem->setClassName2($ClassCategory2->getClassName()->getName()); |
1288
|
|
|
} |
1289
|
|
|
$Shipping->addShipmentItem($ShipmentItem); |
1290
|
|
|
$app['orm.em']->persist($ShipmentItem); |
1291
|
|
|
|
1292
|
|
|
// 配送料金の設定 |
1293
|
|
|
$app['eccube.service.shopping']->setShippingDeliveryFee($Shipping); |
1294
|
|
|
} |
1295
|
|
|
} |
1296
|
|
|
} |
1297
|
|
|
// 配送先を更新 |
1298
|
|
|
$app['orm.em']->flush(); |
1299
|
|
|
|
1300
|
|
|
$event = new EventArgs( |
1301
|
|
|
array( |
1302
|
|
|
'form' => $form, |
1303
|
|
|
'Order' => $Order, |
1304
|
|
|
), |
1305
|
|
|
$request |
1306
|
|
|
); |
1307
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_SHIPPING_MULTIPLE_COMPLETE, $event); |
1308
|
|
|
|
1309
|
|
|
return $app->redirect($app->url('shopping')); |
1310
|
|
|
} |
1311
|
|
|
|
1312
|
|
|
return $app->render( |
1313
|
|
|
'Shopping/shipping_multiple.twig', |
1314
|
|
|
array( |
1315
|
|
|
'form' => $form->createView(), |
1316
|
|
|
'shipmentItems' => $shipmentItems, |
1317
|
|
|
'compItemQuantities' => $compItemQuantities, |
1318
|
|
|
'errors' => $errors, |
1319
|
|
|
) |
1320
|
|
|
); |
1321
|
|
|
} |
1322
|
|
|
|
1323
|
|
|
/** |
|
|
|
|
1324
|
|
|
* 非会員用複数配送設定時の新規お届け先の設定 |
1325
|
|
|
*/ |
|
|
|
|
1326
|
|
|
public function shippingMultipleEdit(Application $app, Request $request) |
1327
|
|
|
{ |
1328
|
|
|
// カートチェック |
1329
|
|
|
if (!$app['eccube.service.cart']->isLocked()) { |
1330
|
|
|
// カートが存在しない、カートがロックされていない時はエラー |
1331
|
|
|
return $app->redirect($app->url('cart')); |
1332
|
|
|
} |
1333
|
|
|
|
1334
|
|
|
// 非会員用Customerを取得 |
1335
|
|
|
$Customer = $app['eccube.service.shopping']->getNonMember($this->sessionKey); |
1336
|
|
|
$CustomerAddress = new CustomerAddress(); |
1337
|
|
|
$CustomerAddress->setCustomer($Customer); |
1338
|
|
|
$Customer->addCustomerAddress($CustomerAddress); |
1339
|
|
|
|
1340
|
|
|
$builder = $app['form.factory']->createBuilder('shopping_shipping', $CustomerAddress); |
1341
|
|
|
|
1342
|
|
|
$event = new EventArgs( |
1343
|
|
|
array( |
1344
|
|
|
'builder' => $builder, |
1345
|
|
|
'Customer' => $Customer, |
1346
|
|
|
), |
1347
|
|
|
$request |
1348
|
|
|
); |
1349
|
|
|
$app['eccube.event.dispatcher']->dispatch( |
1350
|
|
|
EccubeEvents::FRONT_SHOPPING_SHIPPING_MULTIPLE_EDIT_INITIALIZE, |
1351
|
|
|
$event |
1352
|
|
|
); |
1353
|
|
|
|
1354
|
|
|
$form = $builder->getForm(); |
1355
|
|
|
|
1356
|
|
|
$form->handleRequest($request); |
1357
|
|
|
|
1358
|
|
|
if ($form->isSubmitted() && $form->isValid()) { |
1359
|
|
|
// 非会員用のセッションに追加 |
1360
|
|
|
$customerAddresses = $app['session']->get($this->sessionCustomerAddressKey); |
1361
|
|
|
$customerAddresses = unserialize($customerAddresses); |
1362
|
|
|
$customerAddresses[] = $CustomerAddress; |
1363
|
|
|
$app['session']->set($this->sessionCustomerAddressKey, serialize($customerAddresses)); |
1364
|
|
|
|
1365
|
|
|
$event = new EventArgs( |
1366
|
|
|
array( |
1367
|
|
|
'form' => $form, |
1368
|
|
|
'CustomerAddresses' => $customerAddresses, |
1369
|
|
|
), |
1370
|
|
|
$request |
1371
|
|
|
); |
1372
|
|
|
$app['eccube.event.dispatcher']->dispatch( |
1373
|
|
|
EccubeEvents::FRONT_SHOPPING_SHIPPING_MULTIPLE_EDIT_COMPLETE, |
1374
|
|
|
$event |
1375
|
|
|
); |
1376
|
|
|
|
1377
|
|
|
return $app->redirect($app->url('shopping_shipping_multiple')); |
1378
|
|
|
} |
1379
|
|
|
|
1380
|
|
|
return $app->render( |
1381
|
|
|
'Shopping/shipping_multiple_edit.twig', |
1382
|
|
|
array( |
1383
|
|
|
'form' => $form->createView(), |
1384
|
|
|
) |
1385
|
|
|
); |
1386
|
|
|
} |
1387
|
|
|
|
1388
|
|
|
/** |
|
|
|
|
1389
|
|
|
* 購入エラー画面表示 |
1390
|
|
|
*/ |
|
|
|
|
1391
|
|
|
public function shoppingError(Application $app, Request $request) |
1392
|
|
|
{ |
1393
|
|
|
|
1394
|
|
|
$event = new EventArgs( |
1395
|
|
|
array(), |
1396
|
|
|
$request |
1397
|
|
|
); |
1398
|
|
|
$app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_SHOPPING_SHIPPING_ERROR_COMPLETE, $event); |
1399
|
|
|
|
1400
|
|
|
if ($event->getResponse() !== null) { |
1401
|
|
|
return $event->getResponse(); |
1402
|
|
|
} |
1403
|
|
|
|
1404
|
|
|
return $app->render('Shopping/shopping_error.twig'); |
1405
|
|
|
} |
1406
|
|
|
|
1407
|
|
|
/** |
1408
|
|
|
* 非会員でのお客様情報変更時の入力チェック |
1409
|
|
|
* @param $data リクエストパラメータ |
1410
|
|
|
*/ |
1411
|
|
|
private function customerValidation($app, $data) |
1412
|
|
|
{ |
1413
|
|
|
// 入力チェック |
1414
|
|
|
$errors = array(); |
1415
|
|
|
|
1416
|
|
|
$errors[] = $app['validator']->validateValue( |
1417
|
|
|
$data['customer_name01'], |
1418
|
|
|
array( |
1419
|
|
|
new Assert\NotBlank(), |
1420
|
|
|
new Assert\Length(array('max' => $app['config']['name_len'],)), |
|
|
|
|
1421
|
|
|
new Assert\Regex( |
1422
|
|
|
array('pattern' => '/^[^\s ]+$/u', 'message' => 'form.type.name.firstname.nothasspace') |
1423
|
|
|
), |
1424
|
|
|
) |
1425
|
|
|
); |
1426
|
|
|
|
1427
|
|
|
$errors[] = $app['validator']->validateValue( |
1428
|
|
|
$data['customer_name02'], |
1429
|
|
|
array( |
1430
|
|
|
new Assert\NotBlank(), |
1431
|
|
|
new Assert\Length(array('max' => $app['config']['name_len'],)), |
|
|
|
|
1432
|
|
|
new Assert\Regex( |
1433
|
|
|
array('pattern' => '/^[^\s ]+$/u', 'message' => 'form.type.name.firstname.nothasspace') |
1434
|
|
|
), |
1435
|
|
|
) |
1436
|
|
|
); |
1437
|
|
|
|
1438
|
|
|
$errors[] = $app['validator']->validateValue( |
1439
|
|
|
$data['customer_company_name'], |
1440
|
|
|
array( |
1441
|
|
|
new Assert\Length(array('max' => $app['config']['stext_len'])), |
1442
|
|
|
) |
1443
|
|
|
); |
1444
|
|
|
|
1445
|
|
|
$errors[] = $app['validator']->validateValue( |
1446
|
|
|
$data['customer_tel01'], |
1447
|
|
|
array( |
1448
|
|
|
new Assert\NotBlank(), |
1449
|
|
|
new Assert\Type(array('type' => 'numeric', 'message' => 'form.type.numeric.invalid')), |
1450
|
|
|
new Assert\Length(array('max' => $app['config']['tel_len'], 'min' => $app['config']['tel_len_min'])), |
1451
|
|
|
) |
1452
|
|
|
); |
1453
|
|
|
|
1454
|
|
|
$errors[] = $app['validator']->validateValue( |
1455
|
|
|
$data['customer_tel02'], |
1456
|
|
|
array( |
1457
|
|
|
new Assert\NotBlank(), |
1458
|
|
|
new Assert\Type(array('type' => 'numeric', 'message' => 'form.type.numeric.invalid')), |
1459
|
|
|
new Assert\Length(array('max' => $app['config']['tel_len'], 'min' => $app['config']['tel_len_min'])), |
1460
|
|
|
) |
1461
|
|
|
); |
1462
|
|
|
|
1463
|
|
|
$errors[] = $app['validator']->validateValue( |
1464
|
|
|
$data['customer_tel03'], |
1465
|
|
|
array( |
1466
|
|
|
new Assert\NotBlank(), |
1467
|
|
|
new Assert\Type(array('type' => 'numeric', 'message' => 'form.type.numeric.invalid')), |
1468
|
|
|
new Assert\Length(array('max' => $app['config']['tel_len'], 'min' => $app['config']['tel_len_min'])), |
1469
|
|
|
) |
1470
|
|
|
); |
1471
|
|
|
|
1472
|
|
|
$errors[] = $app['validator']->validateValue( |
1473
|
|
|
$data['customer_zip01'], |
1474
|
|
|
array( |
1475
|
|
|
new Assert\NotBlank(), |
1476
|
|
|
new Assert\Type(array('type' => 'numeric', 'message' => 'form.type.numeric.invalid')), |
1477
|
|
|
new Assert\Length(array('min' => $app['config']['zip01_len'], 'max' => $app['config']['zip01_len'])), |
1478
|
|
|
) |
1479
|
|
|
); |
1480
|
|
|
|
1481
|
|
|
$errors[] = $app['validator']->validateValue( |
1482
|
|
|
$data['customer_zip02'], |
1483
|
|
|
array( |
1484
|
|
|
new Assert\NotBlank(), |
1485
|
|
|
new Assert\Type(array('type' => 'numeric', 'message' => 'form.type.numeric.invalid')), |
1486
|
|
|
new Assert\Length(array('min' => $app['config']['zip02_len'], 'max' => $app['config']['zip02_len'])), |
1487
|
|
|
) |
1488
|
|
|
); |
1489
|
|
|
|
1490
|
|
|
$errors[] = $app['validator']->validateValue( |
1491
|
|
|
$data['customer_addr01'], |
1492
|
|
|
array( |
1493
|
|
|
new Assert\NotBlank(), |
1494
|
|
|
new Assert\Length(array('max' => $app['config']['address1_len'])), |
1495
|
|
|
) |
1496
|
|
|
); |
1497
|
|
|
|
1498
|
|
|
$errors[] = $app['validator']->validateValue( |
1499
|
|
|
$data['customer_addr02'], |
1500
|
|
|
array( |
1501
|
|
|
new Assert\NotBlank(), |
1502
|
|
|
new Assert\Length(array('max' => $app['config']['address2_len'])), |
1503
|
|
|
) |
1504
|
|
|
); |
1505
|
|
|
|
1506
|
|
|
$errors[] = $app['validator']->validateValue( |
1507
|
|
|
$data['customer_email'], |
1508
|
|
|
array( |
1509
|
|
|
new Assert\NotBlank(), |
1510
|
|
|
new Assert\Email(), |
1511
|
|
|
) |
1512
|
|
|
); |
1513
|
|
|
|
1514
|
|
|
return $errors; |
1515
|
|
|
} |
1516
|
|
|
} |
1517
|
|
|
|