-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
checkout_payment_address.php
66 lines (49 loc) · 1.98 KB
/
checkout_payment_address.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
<?php
/*
$Id$
CE Phoenix, E-Commerce made Easy
https://phoenixcart.org
Copyright (c) 2021 Phoenix Cart
Released under the GNU General Public License
*/
require 'includes/application_top.php';
require 'includes/system/segments/checkout/pipeline.php';
if (!$customer_data->has('address')) {
Href::redirect($Linker->build('checkout_payment.php'));
}
// needs to be included earlier to set the success message in the messageStack
require language::map_to_translation('checkout_payment_address.php');
$message_stack_area = 'checkout_address';
$error = false;
$process = false;
if (Form::validate_action_is('submit')) {
$customer_details = $customer_data->process($customer_data->get_fields_for_page('address_book'));
$hooks->cat('injectFormVerify');
if (Form::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']);
Href::redirect($Linker->build('checkout_payment.php'));
}
} elseif (isset($_POST['address']) && Form::validate_action_is('select')) {
// process the selected billing destination
$reset_payment = isset($_SESSION['billto'], $_SESSION['payment']) && ($_SESSION['billto'] != $_POST['address']);
$_SESSION['billto'] = $_POST['address'];
if ($customer->fetch_to_address($_SESSION['billto'])) {
if ($reset_payment) {
unset($_SESSION['payment']);
}
Href::redirect($Linker->build('checkout_payment.php'));
} 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_billto');
$billto =& $_SESSION['billto'];
}
$addresses_count = $customer->count_addresses();
require $Template->map(__FILE__, 'page');
require 'includes/application_bottom.php';