-
Notifications
You must be signed in to change notification settings - Fork 14
/
CartTotal.php
77 lines (60 loc) · 1.63 KB
/
CartTotal.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
namespace inklabs\kommerce\Entity;
use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints as Assert;
class CartTotal implements ValidationInterface
{
/** @var int */
public $origSubtotal = 0;
/** @var int */
public $subtotal = 0;
/** @var int */
public $taxSubtotal = 0;
/** @var int */
public $discount = 0;
/** @var int */
public $shipping = 0;
/** @var int */
public $shippingDiscount = 0;
/** @var int */
public $tax = 0;
/** @var int */
public $total = 0;
/** @var int */
public $savings = 0;
/** @var TaxRate */
public $taxRate;
/** @var Coupon[] */
public $coupons = [];
/** @var CartPriceRule[] */
protected $cartPriceRules = [];
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$integerColumns = [
'origSubtotal',
'subtotal',
'taxSubtotal',
'discount',
'shipping',
'shippingDiscount',
'tax',
'total',
'savings',
];
foreach ($integerColumns as $columnName) {
$metadata->addPropertyConstraint($columnName, new Assert\NotNull);
$metadata->addPropertyConstraint($columnName, new Assert\Range([
'min' => 0,
'max' => 4294967295,
]));
}
}
public function getCartPriceRules()
{
return $this->cartPriceRules;
}
public function addCartPriceRule(CartPriceRule $cartPriceRule)
{
$this->cartPriceRules[] = $cartPriceRule;
}
}