-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
44 lines (37 loc) · 1016 Bytes
/
Copy pathfunctions.php
File metadata and controls
44 lines (37 loc) · 1016 Bytes
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
<?php
use \Werlich\Model\Entities\User;
use \Werlich\Model\Repository\RepositoryCart;
function formatPrice(float $price) {
return number_format($price, 2, ',', '.');
}
function formatDate($date) {
return date('d/m/Y', strtotime($date));
}
function checkLogin() {
if (isset($_SESSION[User::SESSION]) && $_SESSION[User::SESSION]->getIduser() > 0) {
return $_SESSION[User::SESSION]->getIduser();
} else {
return 0;
}
}
function getUserName() {
return $_SESSION[User::SESSION]->getNome();
}
function getCartNrQtd() {
$repositorioCart = new RepositoryCart();
$cart = RepositoryCart::getFromSession();
$totals = $repositorioCart->getProducts($cart['idcart']);
$total = 0;
foreach ($totals as $t){
$total += $t['nrqtd'];
}
return $total;
}
function getCartVlSubTotal() {
if (getCartNrQtd() > 0) {
$cart = RepositoryCart::getFromSession();
return formatPrice($cart['vltotal']);
}else{
return "0,00";
}
}