forked from gburton/CE-Phoenix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckout_payment_address.php
More file actions
156 lines (126 loc) · 5.68 KB
/
checkout_payment_address.php
File metadata and controls
156 lines (126 loc) · 5.68 KB
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
<?php
/*
$Id$
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2020 osCommerce
Released under the GNU General Public License
*/
require 'includes/application_top.php';
// if the customer is not logged on, redirect them to the login page
$OSCOM_Hooks->register_pipeline('loginRequired');
// if there is nothing in the customers cart, redirect them to the shopping cart page
if ($_SESSION['cart']->count_contents() < 1) {
tep_redirect(tep_href_link('shopping_cart.php'));
}
if (!$customer_data->has('address')) {
tep_redirect(tep_href_link('checkout_payment.php', '', 'SSL'));
}
$OSCOM_Hooks->register('progress');
// needs to be included earlier to set the success message in the messageStack
require "includes/languages/$language/checkout_payment_address.php";
$message_stack_area = 'checkout_address';
$error = false;
$process = false;
if (tep_validate_form_action_is('submit')) {
$customer_details = $customer_data->process($customer_data->get_fields_for_page('address_book'));
$OSCOM_Hooks->call('siteWide', 'injectFormVerify');
if (tep_form_processing_is_valid()) {
$customer_details['id'] = $customer->get_id();
$customer_data->add_address($customer_details);
$_SESSION['billto'] = $customer_data->get('address_book_id', $customer_details);
unset($_SESSION['payment']);
tep_redirect(tep_href_link('checkout_payment.php', '', 'SSL'));
} elseif (isset($_POST['address'])) {
// process the selected billing destination
$reset_payment = isset($_SESSION['billto']) && ($_SESSION['billto'] != $_POST['address']) && isset($_SESSION['payment']);
$_SESSION['billto'] = $_POST['address'];
if ($customer->fetch_to_address($_SESSION['billto'])) {
if ($reset_payment) {
unset($_SESSION['payment']);
}
tep_redirect(tep_href_link('checkout_payment.php', '', 'SSL'));
} else {
unset($_SESSION['billto']);
}
}
}
// if no billing destination address was selected, use their own address as default
if (!isset($_SESSION['billto'])) {
$_SESSION['billto'] = $customer->get_default_address_id();
$billto =& $_SESSION['billto'];
}
$breadcrumb->add(NAVBAR_TITLE_1, tep_href_link('checkout_payment.php', '', 'SSL'));
$breadcrumb->add(NAVBAR_TITLE_2, tep_href_link('checkout_payment_address.php', '', 'SSL'));
$addresses_count = $customer->count_addresses();
require 'includes/template_top.php';
?>
<h1 class="display-4"><?php echo HEADING_TITLE; ?></h1>
<?php
if ($messageStack->size($message_stack_area) > 0) {
echo $messageStack->output($message_stack_area);
}
?>
<div class="contentContainer">
<div class="row">
<div class="col-sm-7">
<h5 class="mb-1"><?php echo TABLE_HEADING_ADDRESS_BOOK_ENTRIES; ?></h5>
<div><?php echo tep_draw_form('select_address', tep_href_link('checkout_payment_address.php', '', 'SSL'), 'post', '', true); ?>
<table class="table border-right border-left border-bottom table-hover m-0">
<?php
$addresses_query = $customer->get_all_addresses_query();
while ($address = tep_db_fetch_array($addresses_query)) {
?>
<tr class="table-selection">
<td><label for="cpa_<?php echo $address['address_book_id']; ?>"><?php echo $customer_data->get_module('address')->format($address, true, ' ', ', '); ?></label></td>
<td align="text-right">
<div class="custom-control custom-radio custom-control-inline">
<?php
echo tep_draw_radio_field('address', $address['address_book_id'], ($address['address_book_id'] == $_SESSION['billto']), 'id="cpa_' . $address['address_book_id'] . '" aria-describedby="cpa_' . $address['address_book_id'] . '" class="custom-control-input"');
?>
<label class="custom-control-label" for="cpa_<?php echo $address['address_book_id']; ?>"> </label>
</div>
</td>
</tr>
<?php
}
?>
</table>
<div class="buttonSet mt-1">
<?php echo tep_draw_hidden_field('action', 'submit') . tep_draw_button(BUTTON_SELECT_ADDRESS, 'fas fa-user-cog', null, 'primary', null, 'btn-success btn-lg btn-block'); ?>
</div>
</form></div>
</div>
<div class="col-sm-5">
<h5 class="mb-1"><?php echo TABLE_HEADING_PAYMENT_ADDRESS; ?></h5>
<div class="border">
<ul class="list-group list-group-flush">
<li class="list-group-item"><?php echo PAYMENT_FA_ICON . $customer->make_address_label($_SESSION['billto'], true, ' ', '<br>'); ?>
</li>
</ul>
</div>
</div>
</div>
<?php
if ($addresses_count < MAX_ADDRESS_BOOK_ENTRIES) {
?>
<hr>
<h5 class="mb-1"><?php echo TABLE_HEADING_NEW_PAYMENT_ADDRESS; ?></h5>
<p class="font-weight-lighter"><?php echo TEXT_CREATE_NEW_PAYMENT_ADDRESS; ?></p>
<?php
echo tep_draw_form('checkout_new_address', tep_href_link('checkout_payment_address.php', '', 'SSL'), 'post', '', true) . PHP_EOL;
require 'includes/modules/checkout_new_address.php';
echo $OSCOM_Hooks->call('siteWide', 'injectFormDisplay');
echo tep_draw_hidden_field('action', 'submit');
echo tep_draw_button(BUTTON_ADD_NEW_ADDRESS, 'fas fa-user-cog', null, 'primary', null, 'btn-success btn-lg btn-block');
echo '</form>' . PHP_EOL;
}
?>
<div class="buttonSet">
<?php echo tep_draw_button(IMAGE_BUTTON_BACK, 'fas fa-angle-left', tep_href_link('checkout_payment.php', '', 'SSL'), null, null, 'btn-light mt-1'); ?>
</div>
</div>
<?php
require 'includes/template_bottom.php';
require 'includes/application_bottom.php';
?>