|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file has been created by developers from BitBag. |
|
5
|
|
|
* Feel free to contact us once you face any issues or want to start |
|
6
|
|
|
* another great project. |
|
7
|
|
|
* You can find more information about us on https://bitbag.io and write us |
|
8
|
|
|
* an email on [email protected]. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
declare(strict_types=1); |
|
12
|
|
|
|
|
13
|
|
|
namespace BitBag\SyliusVueStorefrontPlugin\Factory\User\OrderHistory; |
|
14
|
|
|
|
|
15
|
|
|
use BitBag\SyliusVueStorefrontPlugin\View\User\OrderHistory\ShippingTotalView; |
|
16
|
|
|
use Sylius\Component\Core\Model\OrderInterface; |
|
17
|
|
|
|
|
18
|
|
|
final class ShippingTotalViewFactory implements ShippingTotalViewFactoryInterface |
|
19
|
|
|
{ |
|
20
|
|
|
/** @var string */ |
|
21
|
|
|
private $shippingTotalViewClass; |
|
22
|
|
|
|
|
23
|
|
|
public function __construct(string $shippingTotalViewClass) |
|
24
|
|
|
{ |
|
25
|
|
|
$this->shippingTotalViewClass = $shippingTotalViewClass; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function create(OrderInterface $syliusOrder): ShippingTotalView |
|
29
|
|
|
{ |
|
30
|
|
|
return $this->createFromOrder($syliusOrder); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
private function createFromOrder(OrderInterface $syliusOrder): ShippingTotalView |
|
34
|
|
|
{ |
|
35
|
|
|
/** @var ShippingTotalView $shippingTotalView */ |
|
36
|
|
|
$shippingTotalView = new $this->shippingTotalViewClass(); |
|
37
|
|
|
$shippingTotalView->base_shipping_amount = $syliusOrder->getShippingTotal(); |
|
38
|
|
|
$shippingTotalView->base_shipping_discount_amount = 0; |
|
39
|
|
|
$shippingTotalView->base_shipping_incl_tax = $syliusOrder->getShippingTotal(); |
|
40
|
|
|
$shippingTotalView->base_shipping_tax_amount = 0; |
|
41
|
|
|
$shippingTotalView->shipping_amount = $syliusOrder->getShippingTotal(); |
|
42
|
|
|
$shippingTotalView->shipping_discount_amount = 0; |
|
43
|
|
|
$shippingTotalView->shipping_discount_tax_compensation_amount = 0; |
|
44
|
|
|
$shippingTotalView->shipping_incl_tax = $syliusOrder->getShippingTotal(); |
|
45
|
|
|
$shippingTotalView->shipping_tax_amount = 0; |
|
46
|
|
|
|
|
47
|
|
|
return $shippingTotalView; |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|