-
Notifications
You must be signed in to change notification settings - Fork 15
/
functions.php
50 lines (40 loc) · 1.17 KB
/
functions.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
<?php
require('database/DBController.php');
require('database/Product.php');
require('database/User.php');
require('database/Cart.php');
$db = new DBController();
$product = new Product($db);
$Cart = new Cart($db);
$product_array = $product->getData();
$top_selection_array = $product->getData('top_selection');
$user = new User($db);
function isMale($user) {
foreach($user->getUserData($_SESSION['login']) as $users) {
if($users['gender'] == "male"){
return true;
} else {
return false;
}
}
}
function calcDiscount($product_price, $cutted_price){
$discount = (($cutted_price - $product_price) / $cutted_price) * 100;
echo intval($discount);
}
function highlightSplit($str) {
$result_array = explode(",",$str);
return $result_array;
}
function getUserId($user) {
$userEmail = $_SESSION['login'];
foreach($user->getUserData($userEmail) as $userIds) {
return $userIds['id'];
}
}
function placeOrders($Cart, $user) {
$userId = getUserId($user);
$product_ids = $Cart->getCartIds($Cart->getData($userId,'cart'));
$Cart->placeOrder($userId, $product_ids);
}
?>