1 | <?php |
||
21 | class ShoppingCart extends \yz\shoppingcart\ShoppingCart |
||
22 | { |
||
23 | /** |
||
24 | * @var AbstractCartPosition[] |
||
25 | */ |
||
26 | protected $_positions = []; |
||
27 | |||
28 | /** |
||
29 | * The cart module. |
||
30 | */ |
||
31 | public $module; |
||
32 | |||
33 | public $currency = 'usd'; |
||
34 | |||
35 | /** |
||
36 | * @return integer |
||
37 | */ |
||
38 | public function getCount() |
||
39 | { |
||
40 | return count($this->_positions); |
||
41 | } |
||
42 | |||
43 | 1 | public function getQuantity() |
|
44 | { |
||
45 | 1 | $count = 0; |
|
46 | 1 | foreach ($this->_positions as $position) { |
|
47 | $count += $position->getQuantity(); |
||
48 | } |
||
49 | |||
50 | 1 | return $count; |
|
51 | } |
||
52 | |||
53 | public function getSubtotal() |
||
54 | { |
||
55 | return $this->getCost(false); |
||
56 | } |
||
57 | |||
58 | public function getTotal() |
||
59 | { |
||
60 | return $this->getCost(true); |
||
61 | } |
||
62 | |||
63 | public function getDiscount() |
||
64 | { |
||
65 | return $this->getTotal() - $this->getSubtotal(); |
||
66 | } |
||
67 | |||
68 | 1 | public function formatCurrency($sum, $currency = null) |
|
72 | |||
73 | /** |
||
74 | * Checks whether any of cart positions has error in `id` attribute. |
||
75 | * @return boolean |
||
76 | */ |
||
77 | public function hasErrors() |
||
87 | } |
||
88 |