-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
cart.php
552 lines (467 loc) · 23.9 KB
/
cart.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
<?php
namespace Opencart\System\Library\Cart;
class Cart {
private array $data = [];
private \Opencart\System\Engine\Config $config;
private \Opencart\System\Library\Cart\Customer $customer;
private \Opencart\System\Library\Session $session;
private \Opencart\System\Library\DB $db;
private \Opencart\System\Library\Cart\Tax $tax;
private \Opencart\System\Library\Cart\Weight $weight;
/**
* Constructor
*
* @param object $registry
*/
public function __construct(\Opencart\System\Engine\Registry $registry) {
$this->config = $registry->get('config');
$this->customer = $registry->get('customer');
$this->session = $registry->get('session');
$this->db = $registry->get('db');
$this->tax = $registry->get('tax');
$this->weight = $registry->get('weight');
// Remove all the expired carts with no customer ID
$this->db->query("DELETE FROM `" . DB_PREFIX . "cart` WHERE (`api_id` > '0' OR `customer_id` = '0') AND `date_added` < DATE_SUB(NOW(), INTERVAL 1 HOUR)");
if ($this->customer->isLogged()) {
// We want to change the session ID on all the old items in the customers cart
$this->db->query("UPDATE `" . DB_PREFIX . "cart` SET `session_id` = '" . $this->db->escape($this->session->getId()) . "' WHERE `api_id` = '0' AND `customer_id` = '" . (int)$this->customer->getId() . "'");
// Once the customer is logged in we want to update the customers cart
$cart_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "cart` WHERE `api_id` = '0' AND `customer_id` = '0' AND `session_id` = '" . $this->db->escape($this->session->getId()) . "'");
foreach ($cart_query->rows as $cart) {
$this->db->query("DELETE FROM `" . DB_PREFIX . "cart` WHERE `cart_id` = '" . (int)$cart['cart_id'] . "'");
// The advantage of using $this->add is that it will check if the products already exist and increase the quantity if necessary.
$this->add($cart['product_id'], $cart['quantity'], json_decode($cart['option'], true), $cart['subscription_plan_id']);
}
}
}
/**
* getProducts
*
* @return array
*/
public function getProducts(): array {
if (!$this->data) {
$cart_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "cart` WHERE `api_id` = '" . (isset($this->session->data['api_id']) ? (int)$this->session->data['api_id'] : 0) . "' AND `customer_id` = '" . (int)$this->customer->getId() . "' AND `session_id` = '" . $this->db->escape($this->session->getId()) . "'");
foreach ($cart_query->rows as $cart) {
$stock = true;
$product_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "product_to_store` `p2s` LEFT JOIN `" . DB_PREFIX . "product` p ON (p2s.`product_id` = p.`product_id`) LEFT JOIN `" . DB_PREFIX . "product_description` pd ON (p.`product_id` = pd.`product_id`) WHERE p2s.`store_id` = '" . (int)$this->config->get('config_store_id') . "' AND p2s.`product_id` = '" . (int)$cart['product_id'] . "' AND pd.`language_id` = '" . (int)$this->config->get('config_language_id') . "' AND p.`date_available` <= NOW() AND p.`status` = '1'");
if ($product_query->num_rows && ($cart['quantity'] > 0)) {
$option_price = 0;
$option_points = 0;
$option_weight = 0;
$option_data = [];
$product_options = (array)json_decode($cart['option'], true);
// Merge variant code with options
$variant = json_decode($product_query->row['variant'], true);
if ($variant) {
foreach ($variant as $key => $value) {
$product_options[$key] = $value;
}
}
foreach ($product_options as $product_option_id => $value) {
if (!$product_query->row['master_id']) {
$product_id = $cart['product_id'];
} else {
$product_id = $product_query->row['master_id'];
}
$option_query = $this->db->query("SELECT po.`product_option_id`, po.`option_id`, od.`name`, o.`type` FROM `" . DB_PREFIX . "product_option` po LEFT JOIN `" . DB_PREFIX . "option` o ON (po.`option_id` = o.`option_id`) LEFT JOIN `" . DB_PREFIX . "option_description` od ON (o.`option_id` = od.`option_id`) WHERE po.`product_option_id` = '" . (int)$product_option_id . "' AND po.`product_id` = '" . (int)$product_id . "' AND od.`language_id` = '" . (int)$this->config->get('config_language_id') . "'");
if ($option_query->num_rows) {
if ($option_query->row['type'] == 'select' || $option_query->row['type'] == 'radio') {
$option_value_query = $this->db->query("SELECT pov.`option_value_id`, ovd.`name`, pov.`quantity`, pov.`subtract`, pov.`price`, pov.`price_prefix`, pov.`points`, pov.`points_prefix`, pov.`weight`, pov.`weight_prefix` FROM `" . DB_PREFIX . "product_option_value` pov LEFT JOIN `" . DB_PREFIX . "option_value` ov ON (pov.`option_value_id` = ov.`option_value_id`) LEFT JOIN `" . DB_PREFIX . "option_value_description` ovd ON (ov.`option_value_id` = ovd.`option_value_id`) WHERE pov.`product_option_value_id` = '" . (int)$value . "' AND pov.`product_option_id` = '" . (int)$product_option_id . "' AND ovd.`language_id` = '" . (int)$this->config->get('config_language_id') . "'");
if ($option_value_query->num_rows) {
if ($option_value_query->row['price_prefix'] == '+') {
$option_price += $option_value_query->row['price'];
} elseif ($option_value_query->row['price_prefix'] == '-') {
$option_price -= $option_value_query->row['price'];
}
if ($option_value_query->row['points_prefix'] == '+') {
$option_points += $option_value_query->row['points'];
} elseif ($option_value_query->row['points_prefix'] == '-') {
$option_points -= $option_value_query->row['points'];
}
if ($option_value_query->row['weight_prefix'] == '+') {
$option_weight += $option_value_query->row['weight'];
} elseif ($option_value_query->row['weight_prefix'] == '-') {
$option_weight -= $option_value_query->row['weight'];
}
if ($option_value_query->row['subtract'] && (!$option_value_query->row['quantity'] || ($option_value_query->row['quantity'] < $cart['quantity']))) {
$stock = false;
}
$option_data[] = [
'product_option_id' => $product_option_id,
'product_option_value_id' => $value,
'option_id' => $option_query->row['option_id'],
'option_value_id' => $option_value_query->row['option_value_id'],
'name' => $option_query->row['name'],
'value' => $option_value_query->row['name'],
'type' => $option_query->row['type'],
'quantity' => $option_value_query->row['quantity'],
'subtract' => $option_value_query->row['subtract'],
'price' => $option_value_query->row['price'],
'price_prefix' => $option_value_query->row['price_prefix'],
'points' => $option_value_query->row['points'],
'points_prefix' => $option_value_query->row['points_prefix'],
'weight' => $option_value_query->row['weight'],
'weight_prefix' => $option_value_query->row['weight_prefix']
];
}
} elseif ($option_query->row['type'] == 'checkbox' && is_array($value)) {
foreach ($value as $product_option_value_id) {
$option_value_query = $this->db->query("SELECT pov.`option_value_id`, pov.`quantity`, pov.`subtract`, pov.`price`, pov.`price_prefix`, pov.`points`, pov.`points_prefix`, pov.`weight`, pov.`weight_prefix`, ovd.`name` FROM `" . DB_PREFIX . "product_option_value` `pov` LEFT JOIN `" . DB_PREFIX . "option_value_description` ovd ON (pov.`option_value_id` = ovd.option_value_id) WHERE pov.product_option_value_id = '" . (int)$product_option_value_id . "' AND pov.product_option_id = '" . (int)$product_option_id . "' AND ovd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
if ($option_value_query->num_rows) {
if ($option_value_query->row['price_prefix'] == '+') {
$option_price += $option_value_query->row['price'];
} elseif ($option_value_query->row['price_prefix'] == '-') {
$option_price -= $option_value_query->row['price'];
}
if ($option_value_query->row['points_prefix'] == '+') {
$option_points += $option_value_query->row['points'];
} elseif ($option_value_query->row['points_prefix'] == '-') {
$option_points -= $option_value_query->row['points'];
}
if ($option_value_query->row['weight_prefix'] == '+') {
$option_weight += $option_value_query->row['weight'];
} elseif ($option_value_query->row['weight_prefix'] == '-') {
$option_weight -= $option_value_query->row['weight'];
}
if ($option_value_query->row['subtract'] && (!$option_value_query->row['quantity'] || ($option_value_query->row['quantity'] < $cart['quantity']))) {
$stock = false;
}
$option_data[] = [
'product_option_id' => $product_option_id,
'product_option_value_id' => $product_option_value_id,
'option_id' => $option_query->row['option_id'],
'option_value_id' => $option_value_query->row['option_value_id'],
'name' => $option_query->row['name'],
'value' => $option_value_query->row['name'],
'type' => $option_query->row['type'],
'quantity' => $option_value_query->row['quantity'],
'subtract' => $option_value_query->row['subtract'],
'price' => $option_value_query->row['price'],
'price_prefix' => $option_value_query->row['price_prefix'],
'points' => $option_value_query->row['points'],
'points_prefix' => $option_value_query->row['points_prefix'],
'weight' => $option_value_query->row['weight'],
'weight_prefix' => $option_value_query->row['weight_prefix']
];
}
}
} elseif ($option_query->row['type'] == 'text' || $option_query->row['type'] == 'textarea' || $option_query->row['type'] == 'file' || $option_query->row['type'] == 'date' || $option_query->row['type'] == 'datetime' || $option_query->row['type'] == 'time') {
$option_data[] = [
'product_option_id' => $product_option_id,
'product_option_value_id' => '',
'option_id' => $option_query->row['option_id'],
'option_value_id' => '',
'name' => $option_query->row['name'],
'value' => $value,
'type' => $option_query->row['type'],
'quantity' => '',
'subtract' => '',
'price' => '',
'price_prefix' => '',
'points' => '',
'points_prefix' => '',
'weight' => '',
'weight_prefix' => ''
];
}
}
}
$price = $product_query->row['price'];
// Product Discounts
$discount_quantity = 0;
foreach ($cart_query->rows as $cart_2) {
if ($cart_2['product_id'] == $cart['product_id']) {
$discount_quantity += $cart_2['quantity'];
}
}
$product_discount_query = $this->db->query("SELECT `price` FROM `" . DB_PREFIX . "product_discount` WHERE `product_id` = '" . (int)$cart['product_id'] . "' AND `customer_group_id` = '" . (int)$this->config->get('config_customer_group_id') . "' AND `quantity` <= '" . (int)$discount_quantity . "' AND ((`date_start` = '0000-00-00' OR `date_start` < NOW()) AND (`date_end` = '0000-00-00' OR `date_end` > NOW())) ORDER BY `quantity` DESC, `priority` ASC, `price` ASC LIMIT 1");
if ($product_discount_query->num_rows) {
$price = $product_discount_query->row['price'];
}
// Product Specials
$product_special_query = $this->db->query("SELECT `price` FROM `" . DB_PREFIX . "product_special` WHERE `product_id` = '" . (int)$cart['product_id'] . "' AND `customer_group_id` = '" . (int)$this->config->get('config_customer_group_id') . "' AND ((`date_start` = '0000-00-00' OR `date_start` < NOW()) AND (`date_end` = '0000-00-00' OR `date_end` > NOW())) ORDER BY `priority` ASC, `price` ASC LIMIT 1");
if ($product_special_query->num_rows) {
$price = $product_special_query->row['price'];
}
$product_total = 0;
foreach ($cart_query->rows as $cart_2) {
if ($cart_2['product_id'] == $cart['product_id']) {
$product_total += $cart_2['quantity'];
}
}
if ($product_query->row['minimum'] > $product_total) {
$minimum = false;
} else {
$minimum = true;
}
// Reward Points
$product_reward_query = $this->db->query("SELECT `points` FROM `" . DB_PREFIX . "product_reward` WHERE `product_id` = '" . (int)$cart['product_id'] . "' AND `customer_group_id` = '" . (int)$this->config->get('config_customer_group_id') . "'");
if ($product_reward_query->num_rows) {
$reward = $product_reward_query->row['points'];
} else {
$reward = 0;
}
// Downloads
$download_data = [];
$download_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "product_to_download` p2d LEFT JOIN `" . DB_PREFIX . "download` d ON (p2d.`download_id` = d.`download_id`) LEFT JOIN `" . DB_PREFIX . "download_description` dd ON (d.`download_id` = dd.`download_id`) WHERE p2d.`product_id` = '" . (int)$cart['product_id'] . "' AND dd.`language_id` = '" . (int)$this->config->get('config_language_id') . "'");
foreach ($download_query->rows as $download) {
$download_data[] = [
'download_id' => $download['download_id'],
'name' => $download['name'],
'filename' => $download['filename'],
'mask' => $download['mask']
];
}
// Stock
if (!$product_query->row['quantity'] || ($product_query->row['quantity'] < $cart['quantity'])) {
$stock = false;
}
$subscription_data = [];
$subscription_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "product_subscription` ps LEFT JOIN `" . DB_PREFIX . "subscription_plan` sp ON (ps.`subscription_plan_id` = sp.`subscription_plan_id`) LEFT JOIN `" . DB_PREFIX . "subscription_plan_description` spd ON (sp.`subscription_plan_id` = spd.`subscription_plan_id`) WHERE ps.`product_id` = '" . (int)$cart['product_id'] . "' AND ps.`subscription_plan_id` = '" . (int)$cart['subscription_plan_id'] . "' AND ps.`customer_group_id` = '" . (int)$this->config->get('config_customer_group_id') . "' AND spd.`language_id` = '" . (int)$this->config->get('config_language_id') . "' AND sp.`status` = '1'");
if ($subscription_query->num_rows) {
$subscription_data = [
'subscription_plan_id' => $subscription_query->row['subscription_plan_id'],
'name' => $subscription_query->row['name'],
'description' => $subscription_query->row['description'],
'trial_price' => $subscription_query->row['trial_price'],
'trial_frequency' => $subscription_query->row['trial_frequency'],
'trial_cycle' => $subscription_query->row['trial_cycle'],
'trial_duration' => $subscription_query->row['trial_duration'],
'trial_remaining' => $subscription_query->row['trial_duration'],
'trial_status' => $subscription_query->row['trial_status'],
'price' => $subscription_query->row['price'],
'frequency' => $subscription_query->row['frequency'],
'cycle' => $subscription_query->row['cycle'],
'duration' => $subscription_query->row['duration'],
'remaining' => $subscription_query->row['duration'],
'status' => $subscription_query->row['status']
];
}
$this->data[] = [
'cart_id' => $cart['cart_id'],
'product_id' => $product_query->row['product_id'],
'master_id' => $product_query->row['master_id'],
'name' => $product_query->row['name'],
'model' => $product_query->row['model'],
'shipping' => $product_query->row['shipping'],
'image' => $product_query->row['image'],
'option' => $option_data,
'subscription' => $subscription_data,
'download' => $download_data,
'quantity' => $cart['quantity'],
'minimum' => $minimum,
'subtract' => $product_query->row['subtract'],
'stock' => $stock,
'price' => ($price + $option_price),
'total' => ($price + $option_price) * $cart['quantity'],
'reward' => $reward * $cart['quantity'],
'points' => ($product_query->row['points'] ? ($product_query->row['points'] + $option_points) * $cart['quantity'] : 0),
'tax_class_id' => $product_query->row['tax_class_id'],
'weight' => ($product_query->row['weight'] + $option_weight) * $cart['quantity'],
'weight_class_id' => $product_query->row['weight_class_id'],
'length' => $product_query->row['length'],
'width' => $product_query->row['width'],
'height' => $product_query->row['height'],
'length_class_id' => $product_query->row['length_class_id']
];
} else {
$this->remove($cart['cart_id']);
}
}
}
return $this->data;
}
/**
* Add
*
* @param int $product_id
* @param int $quantity
* @param array $option
* @param int $subscription_plan_id
*
* @return void
*/
public function add(int $product_id, int $quantity = 1, array $option = [], int $subscription_plan_id = 0): void {
$query = $this->db->query("SELECT COUNT(*) AS `total` FROM `" . DB_PREFIX . "cart` WHERE `api_id` = '" . (isset($this->session->data['api_id']) ? (int)$this->session->data['api_id'] : 0) . "' AND `customer_id` = '" . (int)$this->customer->getId() . "' AND `session_id` = '" . $this->db->escape($this->session->getId()) . "' AND `product_id` = '" . (int)$product_id . "' AND `subscription_plan_id` = '" . (int)$subscription_plan_id . "' AND `option` = '" . $this->db->escape(json_encode($option)) . "'");
if (!$query->row['total']) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "cart` SET `api_id` = '" . (isset($this->session->data['api_id']) ? (int)$this->session->data['api_id'] : 0) . "', `customer_id` = '" . (int)$this->customer->getId() . "', `session_id` = '" . $this->db->escape($this->session->getId()) . "', `product_id` = '" . (int)$product_id . "', `subscription_plan_id` = '" . (int)$subscription_plan_id . "', `option` = '" . $this->db->escape(json_encode($option)) . "', `quantity` = '" . (int)$quantity . "', `date_added` = NOW()");
} else {
$this->db->query("UPDATE `" . DB_PREFIX . "cart` SET `quantity` = (`quantity` + " . (int)$quantity . ") WHERE `api_id` = '" . (isset($this->session->data['api_id']) ? (int)$this->session->data['api_id'] : 0) . "' AND `customer_id` = '" . (int)$this->customer->getId() . "' AND `session_id` = '" . $this->db->escape($this->session->getId()) . "' AND `product_id` = '" . (int)$product_id . "' AND `subscription_plan_id` = '" . (int)$subscription_plan_id . "' AND `option` = '" . $this->db->escape(json_encode($option)) . "'");
}
$this->data = [];
}
/**
* Update
*
* @param int $cart_id
* @param int $quantity
*
* @return void
*/
public function update(int $cart_id, int $quantity): void {
$this->db->query("UPDATE `" . DB_PREFIX . "cart` SET `quantity` = '" . (int)$quantity . "' WHERE `cart_id` = '" . (int)$cart_id . "' AND `api_id` = '" . (isset($this->session->data['api_id']) ? (int)$this->session->data['api_id'] : 0) . "' AND `customer_id` = '" . (int)$this->customer->getId() . "' AND `session_id` = '" . $this->db->escape($this->session->getId()) . "'");
$this->data = [];
}
/**
* Remove
*
* @param int $cart_id
*
* @return void
*/
public function remove(int $cart_id): void {
$this->db->query("DELETE FROM `" . DB_PREFIX . "cart` WHERE `cart_id` = '" . (int)$cart_id . "' AND `api_id` = '" . (isset($this->session->data['api_id']) ? (int)$this->session->data['api_id'] : 0) . "' AND `customer_id` = '" . (int)$this->customer->getId() . "' AND `session_id` = '" . $this->db->escape($this->session->getId()) . "'");
$this->data = [];
}
/**
* Clear
*
* @return void
*/
public function clear(): void {
$this->db->query("DELETE FROM `" . DB_PREFIX . "cart` WHERE `api_id` = '" . (isset($this->session->data['api_id']) ? (int)$this->session->data['api_id'] : 0) . "' AND `customer_id` = '" . (int)$this->customer->getId() . "' AND `session_id` = '" . $this->db->escape($this->session->getId()) . "'");
$this->data = [];
}
/**
* getSubscription
*
* @return array
*/
public function getSubscription(): array {
$product_data = [];
foreach ($this->getProducts() as $value) {
if ($value['subscription']) {
$product_data[] = $value;
}
}
return $product_data;
}
/**
* getWeight
*
* @return float
*/
public function getWeight(): float {
$weight = 0;
foreach ($this->getProducts() as $product) {
if ($product['shipping']) {
$weight += $this->weight->convert($product['weight'], $product['weight_class_id'], $this->config->get('config_weight_class_id'));
}
}
return $weight;
}
/**
* getSubTotal
*
* @return float
*/
public function getSubTotal(): float {
$total = 0;
foreach ($this->getProducts() as $product) {
$total += $product['total'];
}
return $total;
}
/**
* getTaxes
*
* @return array
*/
public function getTaxes(): array {
$tax_data = [];
foreach ($this->getProducts() as $product) {
if ($product['tax_class_id']) {
$tax_rates = $this->tax->getRates($product['price'], $product['tax_class_id']);
foreach ($tax_rates as $tax_rate) {
if (!isset($tax_data[$tax_rate['tax_rate_id']])) {
$tax_data[$tax_rate['tax_rate_id']] = ($tax_rate['amount'] * $product['quantity']);
} else {
$tax_data[$tax_rate['tax_rate_id']] += ($tax_rate['amount'] * $product['quantity']);
}
}
}
}
return $tax_data;
}
/**
* getTotal
*
* @return float
*/
public function getTotal(): float {
$total = 0;
foreach ($this->getProducts() as $product) {
$total += $this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax')) * $product['quantity'];
}
return $total;
}
/**
* countProducts
*
* @return int
*/
public function countProducts(): int {
$product_total = 0;
$products = $this->getProducts();
foreach ($products as $product) {
$product_total += $product['quantity'];
}
return $product_total;
}
/**
* hadProducts
*
* @return bool
*/
public function hasProducts(): bool {
return count($this->getProducts());
}
/**
* hasSubscription
*
* @return bool
*/
public function hasSubscription(): bool {
return count($this->getSubscription());
}
/**
* hasStock
*
* @return bool
*/
public function hasStock(): bool {
foreach ($this->getProducts() as $product) {
if (!$product['stock']) {
return false;
}
}
return true;
}
/**
* hasShipping
*
* @return bool
*/
public function hasShipping(): bool {
foreach ($this->getProducts() as $product) {
if ($product['shipping']) {
return true;
}
}
return false;
}
/**
* hasDownload
*
* @return bool
*/
public function hasDownload(): bool {
foreach ($this->getProducts() as $product) {
if ($product['download']) {
return true;
}
}
return false;
}
}