|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Sylius package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Paweł Jędrzejewski |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Sylius\Component\Core\OrderProcessing; |
|
13
|
|
|
|
|
14
|
|
|
use Sylius\Component\Core\Model\OrderInterface; |
|
15
|
|
|
use Sylius\Component\Core\Taxation\OrderTaxesApplicatorInterface; |
|
16
|
|
|
use Sylius\Component\Promotion\Processor\PromotionProcessorInterface; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @author Jan Góralski <[email protected]> |
|
20
|
|
|
*/ |
|
21
|
|
|
class OrderRecalculator implements OrderRecalculatorInterface |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @var PromotionProcessorInterface |
|
25
|
|
|
*/ |
|
26
|
|
|
private $promotionProcessor; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var OrderTaxesApplicatorInterface |
|
30
|
|
|
*/ |
|
31
|
|
|
private $taxesApplicator; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @var ShippingChargesProcessorInterface |
|
35
|
|
|
*/ |
|
36
|
|
|
private $shippingChargesProcessor; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @param PromotionProcessorInterface $promotionProcessor |
|
40
|
|
|
* @param OrderTaxesApplicatorInterface $taxesApplicator |
|
41
|
|
|
* @param ShippingChargesProcessorInterface $shippingChargesProcessor |
|
42
|
|
|
*/ |
|
43
|
|
|
public function __construct( |
|
44
|
|
|
PromotionProcessorInterface $promotionProcessor, |
|
45
|
|
|
OrderTaxesApplicatorInterface $taxesApplicator, |
|
46
|
|
|
ShippingChargesProcessorInterface $shippingChargesProcessor |
|
47
|
|
|
) { |
|
48
|
|
|
$this->promotionProcessor = $promotionProcessor; |
|
49
|
|
|
$this->taxesApplicator = $taxesApplicator; |
|
50
|
|
|
$this->shippingChargesProcessor = $shippingChargesProcessor; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @param OrderInterface $order |
|
55
|
|
|
* |
|
56
|
|
|
* @return OrderInterface |
|
57
|
|
|
*/ |
|
58
|
|
|
public function recalculate(OrderInterface $order) |
|
59
|
|
|
{ |
|
60
|
|
|
$this->promotionProcessor->process($order); |
|
61
|
|
|
$this->taxesApplicator->apply($order); |
|
62
|
|
|
$this->shippingChargesProcessor->applyShippingCharges($order); |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|