forked from castlamp/zenbership
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cart.php
102 lines (95 loc) · 2.64 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
<?php
/**
*
*
* Zenbership Membership Software
* Copyright (C) 2013-2016 Castlamp, LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @author Castlamp
* @link http://www.castlamp.com/
* @link http://www.zenbership.com/
* @copyright (c) 2013-2016 Castlamp
* @license http://www.gnu.org/licenses/gpl-3.0.en.html
* @project Zenbership Membership Software
*/
// Load the basics
require "admin/sd-system/config.php";
$cart = new cart();
if (! empty($_GET['reset'])) {
$cart->reset_cart();
header('Location: ' . PP_URL . '/catalog.php');
exit;
}
if (! empty($cart->order['data']['reg_session'])) {
header('Location: ' . PP_URL . '/register.php?id=' . $cart->order['data']['reg_session'] . '&code=F043');
exit;
}
/**
* Permissions:
* 0 : None
* 1 : View Catalog
* 2 : View Cart
* 3 : Checkout
*/
$cart->check_permission('2');
/**
* Delete cookie is applicable
*/
if ($cart->order['data']['status'] == '1') {
$del = $db->delete_cookie('zen_cart');
header('Location: ' . PP_URL . '/cart.php');
exit;
}
/**
* Forced addition?
*/
if (! empty($_GET['id'])) {
if (empty($_GET['qty'])) { $qty = 1; }
else {
if (is_numeric($_GET['qty'])) {
$qty = $_GET['qty'];
} else {
$qty = 1;
}
}
$add = $cart->add($_GET['id'], $qty, '');
if ($add['error'] == '1') {
header('Location: cart.php?code=' . $add['code']);
exit;
} else {
header('Location: cart.php?scode=S068');
exit;
}
}
/**
* View Cart products
*/
if ($cart->order['data']['total_items'] <= 0) {
$panels = '';
$template_name = 'cart_overview_empty';
} else {
$panels = $cart->build_product_blocks($cart->order['components']);
$template_name = 'cart_overview';
}
$changes = array(
'cart_components' => $panels,
'pricing' => $cart->order['pricing'],
'code' => $cart->order['code'],
'data' => $cart->order['data'],
);
$temp = new template($template_name, $changes, '1');
echo $temp;
exit;