|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of EC-CUBE |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright(c) LOCKON CO.,LTD. All Rights Reserved. |
|
7
|
|
|
* |
|
8
|
|
|
* http://www.lockon.co.jp/ |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
11
|
|
|
* file that was distributed with this source code. |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
namespace Eccube\Service\PurchaseFlow\Processor; |
|
15
|
|
|
|
|
16
|
|
|
use Eccube\Entity\BaseInfo; |
|
17
|
|
|
use Eccube\Entity\ItemHolderInterface; |
|
18
|
|
|
use Eccube\Service\PurchaseFlow\ItemHolderPreprocessor; |
|
19
|
|
|
use Eccube\Service\PurchaseFlow\PurchaseContext; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* 送料無料条件を適用します. |
|
23
|
|
|
*/ |
|
24
|
|
|
class DeliveryFeeFreePreprocessor implements ItemHolderPreprocessor |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* @var BaseInfo |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $BaseInfo; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* DeliveryFeeProcessor constructor. |
|
33
|
|
|
* |
|
34
|
|
|
* @param BaseInfo $BaseInfo |
|
35
|
|
|
*/ |
|
36
|
162 |
|
public function __construct(BaseInfo $BaseInfo) |
|
37
|
|
|
{ |
|
38
|
162 |
|
$this->BaseInfo = $BaseInfo; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param ItemHolderInterface $itemHolder |
|
43
|
|
|
* @param PurchaseContext $context |
|
44
|
|
|
*/ |
|
45
|
81 |
|
public function process(ItemHolderInterface $itemHolder, PurchaseContext $context) |
|
46
|
|
|
{ |
|
47
|
81 |
|
$isDeliveryFree = false; |
|
48
|
|
|
|
|
49
|
81 |
|
if ($this->BaseInfo->getDeliveryFreeAmount()) { |
|
50
|
1 |
|
if ($this->BaseInfo->getDeliveryFreeAmount() <= $itemHolder->getTotal()) { |
|
51
|
|
|
// 送料無料(金額)を超えている |
|
52
|
1 |
|
$isDeliveryFree = true; |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
81 |
|
if ($this->BaseInfo->getDeliveryFreeQuantity()) { |
|
57
|
1 |
|
if ($this->BaseInfo->getDeliveryFreeQuantity() <= $itemHolder->getQuantity()) { |
|
58
|
|
|
// 送料無料(個数)を超えている |
|
59
|
1 |
|
$isDeliveryFree = true; |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
// 送料無料条件に合致した場合は、送料明細の個数を0に設定 |
|
64
|
81 |
|
if ($isDeliveryFree) { |
|
65
|
2 |
|
$items = $itemHolder->getItems(); |
|
66
|
2 |
|
foreach ($items as $item) { |
|
67
|
2 |
|
if ($item->isDeliveryFee()) { |
|
68
|
2 |
|
$item->setQuantity(0); |
|
69
|
|
|
} |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|