@@ -21,364 +21,364 @@ |
||
| 21 | 21 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
| 22 | 22 | |
| 23 | 23 | class ControllerCheckoutGuest extends \Sunrise\Core\Engine\Controller { |
| 24 | - public function index() { |
|
| 25 | - $this->load->language('checkout/checkout'); |
|
| 26 | - |
|
| 27 | - $data['text_select'] = $this->language->get('text_select'); |
|
| 28 | - $data['text_none'] = $this->language->get('text_none'); |
|
| 29 | - $data['text_your_details'] = $this->language->get('text_your_details'); |
|
| 30 | - $data['text_your_account'] = $this->language->get('text_your_account'); |
|
| 31 | - $data['text_your_address'] = $this->language->get('text_your_address'); |
|
| 32 | - $data['text_loading'] = $this->language->get('text_loading'); |
|
| 33 | - |
|
| 34 | - $data['entry_firstname'] = $this->language->get('entry_firstname'); |
|
| 35 | - $data['entry_lastname'] = $this->language->get('entry_lastname'); |
|
| 36 | - $data['entry_email'] = $this->language->get('entry_email'); |
|
| 37 | - $data['entry_telephone'] = $this->language->get('entry_telephone'); |
|
| 38 | - $data['entry_fax'] = $this->language->get('entry_fax'); |
|
| 39 | - $data['entry_company'] = $this->language->get('entry_company'); |
|
| 40 | - $data['entry_customer_group'] = $this->language->get('entry_customer_group'); |
|
| 41 | - $data['entry_address_1'] = $this->language->get('entry_address_1'); |
|
| 42 | - $data['entry_address_2'] = $this->language->get('entry_address_2'); |
|
| 43 | - $data['entry_postcode'] = $this->language->get('entry_postcode'); |
|
| 44 | - $data['entry_city'] = $this->language->get('entry_city'); |
|
| 45 | - $data['entry_country'] = $this->language->get('entry_country'); |
|
| 46 | - $data['entry_zone'] = $this->language->get('entry_zone'); |
|
| 47 | - $data['entry_shipping'] = $this->language->get('entry_shipping'); |
|
| 48 | - |
|
| 49 | - $data['button_continue'] = $this->language->get('button_continue'); |
|
| 50 | - $data['button_upload'] = $this->language->get('button_upload'); |
|
| 51 | - |
|
| 52 | - $data['customer_groups'] = array(); |
|
| 53 | - |
|
| 54 | - if (is_array($this->config->get('config_customer_group_display'))) { |
|
| 55 | - $this->load->model('account/customer_group'); |
|
| 56 | - |
|
| 57 | - $customer_groups = $this->model_account_customer_group->getCustomerGroups(); |
|
| 58 | - |
|
| 59 | - foreach ($customer_groups as $customer_group) { |
|
| 60 | - if (in_array($customer_group['customer_group_id'], $this->config->get('config_customer_group_display'))) { |
|
| 61 | - $data['customer_groups'][] = $customer_group; |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - if (isset($this->session->data['guest']['customer_group_id'])) { |
|
| 67 | - $data['customer_group_id'] = $this->session->data['guest']['customer_group_id']; |
|
| 68 | - } else { |
|
| 69 | - $data['customer_group_id'] = $this->config->get('config_customer_group_id'); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - if (isset($this->session->data['guest']['firstname'])) { |
|
| 73 | - $data['firstname'] = $this->session->data['guest']['firstname']; |
|
| 74 | - } else { |
|
| 75 | - $data['firstname'] = ''; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - if (isset($this->session->data['guest']['lastname'])) { |
|
| 79 | - $data['lastname'] = $this->session->data['guest']['lastname']; |
|
| 80 | - } else { |
|
| 81 | - $data['lastname'] = ''; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - if (isset($this->session->data['guest']['email'])) { |
|
| 85 | - $data['email'] = $this->session->data['guest']['email']; |
|
| 86 | - } else { |
|
| 87 | - $data['email'] = ''; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - if (isset($this->session->data['guest']['telephone'])) { |
|
| 91 | - $data['telephone'] = $this->session->data['guest']['telephone']; |
|
| 92 | - } else { |
|
| 93 | - $data['telephone'] = ''; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - if (isset($this->session->data['guest']['fax'])) { |
|
| 97 | - $data['fax'] = $this->session->data['guest']['fax']; |
|
| 98 | - } else { |
|
| 99 | - $data['fax'] = ''; |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - if (isset($this->session->data['payment_address']['company'])) { |
|
| 103 | - $data['company'] = $this->session->data['payment_address']['company']; |
|
| 104 | - } else { |
|
| 105 | - $data['company'] = ''; |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - if (isset($this->session->data['payment_address']['address_1'])) { |
|
| 109 | - $data['address_1'] = $this->session->data['payment_address']['address_1']; |
|
| 110 | - } else { |
|
| 111 | - $data['address_1'] = ''; |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - if (isset($this->session->data['payment_address']['address_2'])) { |
|
| 115 | - $data['address_2'] = $this->session->data['payment_address']['address_2']; |
|
| 116 | - } else { |
|
| 117 | - $data['address_2'] = ''; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - if (isset($this->session->data['payment_address']['postcode'])) { |
|
| 121 | - $data['postcode'] = $this->session->data['payment_address']['postcode']; |
|
| 122 | - } elseif (isset($this->session->data['shipping_address']['postcode'])) { |
|
| 123 | - $data['postcode'] = $this->session->data['shipping_address']['postcode']; |
|
| 124 | - } else { |
|
| 125 | - $data['postcode'] = ''; |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - if (isset($this->session->data['payment_address']['city'])) { |
|
| 129 | - $data['city'] = $this->session->data['payment_address']['city']; |
|
| 130 | - } else { |
|
| 131 | - $data['city'] = ''; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - if (isset($this->session->data['payment_address']['country_id'])) { |
|
| 135 | - $data['country_id'] = $this->session->data['payment_address']['country_id']; |
|
| 136 | - } elseif (isset($this->session->data['shipping_address']['country_id'])) { |
|
| 137 | - $data['country_id'] = $this->session->data['shipping_address']['country_id']; |
|
| 138 | - } else { |
|
| 139 | - $data['country_id'] = $this->config->get('config_country_id'); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - if (isset($this->session->data['payment_address']['zone_id'])) { |
|
| 143 | - $data['zone_id'] = $this->session->data['payment_address']['zone_id']; |
|
| 144 | - } elseif (isset($this->session->data['shipping_address']['zone_id'])) { |
|
| 145 | - $data['zone_id'] = $this->session->data['shipping_address']['zone_id']; |
|
| 146 | - } else { |
|
| 147 | - $data['zone_id'] = ''; |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - $this->load->model('localisation/country'); |
|
| 151 | - |
|
| 152 | - $data['countries'] = $this->model_localisation_country->getCountries(); |
|
| 153 | - |
|
| 154 | - // Custom Fields |
|
| 155 | - $this->load->model('account/custom_field'); |
|
| 156 | - |
|
| 157 | - $data['custom_fields'] = $this->model_account_custom_field->getCustomFields(); |
|
| 158 | - |
|
| 159 | - if (isset($this->session->data['guest']['custom_field'])) { |
|
| 160 | - if (isset($this->session->data['guest']['custom_field'])) { |
|
| 161 | - $guest_custom_field = $this->session->data['guest']['custom_field']; |
|
| 162 | - } else { |
|
| 163 | - $guest_custom_field = array(); |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - if (isset($this->session->data['payment_address']['custom_field'])) { |
|
| 167 | - $address_custom_field = $this->session->data['payment_address']['custom_field']; |
|
| 168 | - } else { |
|
| 169 | - $address_custom_field = array(); |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - $data['guest_custom_field'] = $guest_custom_field + $address_custom_field; |
|
| 173 | - } else { |
|
| 174 | - $data['guest_custom_field'] = array(); |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - $data['shipping_required'] = $this->cart->hasShipping(); |
|
| 178 | - |
|
| 179 | - if (isset($this->session->data['guest']['shipping_address'])) { |
|
| 180 | - $data['shipping_address'] = $this->session->data['guest']['shipping_address']; |
|
| 181 | - } else { |
|
| 182 | - $data['shipping_address'] = true; |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - $this->response->setOutput($this->load->view('checkout/guest', $data)); |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - public function save() { |
|
| 189 | - $this->load->language('checkout/checkout'); |
|
| 190 | - |
|
| 191 | - $json = array(); |
|
| 192 | - |
|
| 193 | - // Validate if customer is logged in. |
|
| 194 | - if ($this->customer->isLogged()) { |
|
| 195 | - $json['redirect'] = $this->url->link('checkout/checkout', '', true); |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - // Validate cart has products and has stock. |
|
| 199 | - if ((!$this->cart->hasProducts()) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { |
|
| 200 | - $json['redirect'] = $this->url->link('checkout/cart'); |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - // Check if guest checkout is available. |
|
| 204 | - if (!$this->config->get('config_checkout_guest') || $this->config->get('config_customer_price') || $this->cart->hasDownload()) { |
|
| 205 | - $json['redirect'] = $this->url->link('checkout/checkout', '', true); |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - if (!$json) { |
|
| 209 | - if ((\voku\helper\UTF8::strlen(trim($this->request->post['firstname'])) < 1) || (\voku\helper\UTF8::strlen(trim($this->request->post['firstname'])) > 32)) { |
|
| 210 | - $json['error']['firstname'] = $this->language->get('error_firstname'); |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - if ((\voku\helper\UTF8::strlen(trim($this->request->post['lastname'])) < 1) || (\voku\helper\UTF8::strlen(trim($this->request->post['lastname'])) > 32)) { |
|
| 214 | - $json['error']['lastname'] = $this->language->get('error_lastname'); |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - if ((\voku\helper\UTF8::strlen($this->request->post['email']) > 96) || !filter_var($this->request->post['email'], FILTER_VALIDATE_EMAIL)) { |
|
| 218 | - $json['error']['email'] = $this->language->get('error_email'); |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - if ((\voku\helper\UTF8::strlen($this->request->post['telephone']) < 3) || (\voku\helper\UTF8::strlen($this->request->post['telephone']) > 32)) { |
|
| 222 | - $json['error']['telephone'] = $this->language->get('error_telephone'); |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - if ((\voku\helper\UTF8::strlen(trim($this->request->post['address_1'])) < 3) || (\voku\helper\UTF8::strlen(trim($this->request->post['address_1'])) > 128)) { |
|
| 226 | - $json['error']['address_1'] = $this->language->get('error_address_1'); |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - if ((\voku\helper\UTF8::strlen(trim($this->request->post['city'])) < 2) || (\voku\helper\UTF8::strlen(trim($this->request->post['city'])) > 128)) { |
|
| 230 | - $json['error']['city'] = $this->language->get('error_city'); |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - $this->load->model('localisation/country'); |
|
| 234 | - |
|
| 235 | - $country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']); |
|
| 236 | - |
|
| 237 | - if ($country_info && $country_info['postcode_required'] && (\voku\helper\UTF8::strlen(trim($this->request->post['postcode'])) < 2 || \voku\helper\UTF8::strlen(trim($this->request->post['postcode'])) > 10)) { |
|
| 238 | - $json['error']['postcode'] = $this->language->get('error_postcode'); |
|
| 239 | - } |
|
| 24 | + public function index() { |
|
| 25 | + $this->load->language('checkout/checkout'); |
|
| 26 | + |
|
| 27 | + $data['text_select'] = $this->language->get('text_select'); |
|
| 28 | + $data['text_none'] = $this->language->get('text_none'); |
|
| 29 | + $data['text_your_details'] = $this->language->get('text_your_details'); |
|
| 30 | + $data['text_your_account'] = $this->language->get('text_your_account'); |
|
| 31 | + $data['text_your_address'] = $this->language->get('text_your_address'); |
|
| 32 | + $data['text_loading'] = $this->language->get('text_loading'); |
|
| 33 | + |
|
| 34 | + $data['entry_firstname'] = $this->language->get('entry_firstname'); |
|
| 35 | + $data['entry_lastname'] = $this->language->get('entry_lastname'); |
|
| 36 | + $data['entry_email'] = $this->language->get('entry_email'); |
|
| 37 | + $data['entry_telephone'] = $this->language->get('entry_telephone'); |
|
| 38 | + $data['entry_fax'] = $this->language->get('entry_fax'); |
|
| 39 | + $data['entry_company'] = $this->language->get('entry_company'); |
|
| 40 | + $data['entry_customer_group'] = $this->language->get('entry_customer_group'); |
|
| 41 | + $data['entry_address_1'] = $this->language->get('entry_address_1'); |
|
| 42 | + $data['entry_address_2'] = $this->language->get('entry_address_2'); |
|
| 43 | + $data['entry_postcode'] = $this->language->get('entry_postcode'); |
|
| 44 | + $data['entry_city'] = $this->language->get('entry_city'); |
|
| 45 | + $data['entry_country'] = $this->language->get('entry_country'); |
|
| 46 | + $data['entry_zone'] = $this->language->get('entry_zone'); |
|
| 47 | + $data['entry_shipping'] = $this->language->get('entry_shipping'); |
|
| 48 | + |
|
| 49 | + $data['button_continue'] = $this->language->get('button_continue'); |
|
| 50 | + $data['button_upload'] = $this->language->get('button_upload'); |
|
| 51 | + |
|
| 52 | + $data['customer_groups'] = array(); |
|
| 53 | + |
|
| 54 | + if (is_array($this->config->get('config_customer_group_display'))) { |
|
| 55 | + $this->load->model('account/customer_group'); |
|
| 56 | + |
|
| 57 | + $customer_groups = $this->model_account_customer_group->getCustomerGroups(); |
|
| 58 | + |
|
| 59 | + foreach ($customer_groups as $customer_group) { |
|
| 60 | + if (in_array($customer_group['customer_group_id'], $this->config->get('config_customer_group_display'))) { |
|
| 61 | + $data['customer_groups'][] = $customer_group; |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + if (isset($this->session->data['guest']['customer_group_id'])) { |
|
| 67 | + $data['customer_group_id'] = $this->session->data['guest']['customer_group_id']; |
|
| 68 | + } else { |
|
| 69 | + $data['customer_group_id'] = $this->config->get('config_customer_group_id'); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + if (isset($this->session->data['guest']['firstname'])) { |
|
| 73 | + $data['firstname'] = $this->session->data['guest']['firstname']; |
|
| 74 | + } else { |
|
| 75 | + $data['firstname'] = ''; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + if (isset($this->session->data['guest']['lastname'])) { |
|
| 79 | + $data['lastname'] = $this->session->data['guest']['lastname']; |
|
| 80 | + } else { |
|
| 81 | + $data['lastname'] = ''; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + if (isset($this->session->data['guest']['email'])) { |
|
| 85 | + $data['email'] = $this->session->data['guest']['email']; |
|
| 86 | + } else { |
|
| 87 | + $data['email'] = ''; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + if (isset($this->session->data['guest']['telephone'])) { |
|
| 91 | + $data['telephone'] = $this->session->data['guest']['telephone']; |
|
| 92 | + } else { |
|
| 93 | + $data['telephone'] = ''; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + if (isset($this->session->data['guest']['fax'])) { |
|
| 97 | + $data['fax'] = $this->session->data['guest']['fax']; |
|
| 98 | + } else { |
|
| 99 | + $data['fax'] = ''; |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + if (isset($this->session->data['payment_address']['company'])) { |
|
| 103 | + $data['company'] = $this->session->data['payment_address']['company']; |
|
| 104 | + } else { |
|
| 105 | + $data['company'] = ''; |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + if (isset($this->session->data['payment_address']['address_1'])) { |
|
| 109 | + $data['address_1'] = $this->session->data['payment_address']['address_1']; |
|
| 110 | + } else { |
|
| 111 | + $data['address_1'] = ''; |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + if (isset($this->session->data['payment_address']['address_2'])) { |
|
| 115 | + $data['address_2'] = $this->session->data['payment_address']['address_2']; |
|
| 116 | + } else { |
|
| 117 | + $data['address_2'] = ''; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + if (isset($this->session->data['payment_address']['postcode'])) { |
|
| 121 | + $data['postcode'] = $this->session->data['payment_address']['postcode']; |
|
| 122 | + } elseif (isset($this->session->data['shipping_address']['postcode'])) { |
|
| 123 | + $data['postcode'] = $this->session->data['shipping_address']['postcode']; |
|
| 124 | + } else { |
|
| 125 | + $data['postcode'] = ''; |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + if (isset($this->session->data['payment_address']['city'])) { |
|
| 129 | + $data['city'] = $this->session->data['payment_address']['city']; |
|
| 130 | + } else { |
|
| 131 | + $data['city'] = ''; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + if (isset($this->session->data['payment_address']['country_id'])) { |
|
| 135 | + $data['country_id'] = $this->session->data['payment_address']['country_id']; |
|
| 136 | + } elseif (isset($this->session->data['shipping_address']['country_id'])) { |
|
| 137 | + $data['country_id'] = $this->session->data['shipping_address']['country_id']; |
|
| 138 | + } else { |
|
| 139 | + $data['country_id'] = $this->config->get('config_country_id'); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + if (isset($this->session->data['payment_address']['zone_id'])) { |
|
| 143 | + $data['zone_id'] = $this->session->data['payment_address']['zone_id']; |
|
| 144 | + } elseif (isset($this->session->data['shipping_address']['zone_id'])) { |
|
| 145 | + $data['zone_id'] = $this->session->data['shipping_address']['zone_id']; |
|
| 146 | + } else { |
|
| 147 | + $data['zone_id'] = ''; |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + $this->load->model('localisation/country'); |
|
| 151 | + |
|
| 152 | + $data['countries'] = $this->model_localisation_country->getCountries(); |
|
| 153 | + |
|
| 154 | + // Custom Fields |
|
| 155 | + $this->load->model('account/custom_field'); |
|
| 156 | + |
|
| 157 | + $data['custom_fields'] = $this->model_account_custom_field->getCustomFields(); |
|
| 158 | + |
|
| 159 | + if (isset($this->session->data['guest']['custom_field'])) { |
|
| 160 | + if (isset($this->session->data['guest']['custom_field'])) { |
|
| 161 | + $guest_custom_field = $this->session->data['guest']['custom_field']; |
|
| 162 | + } else { |
|
| 163 | + $guest_custom_field = array(); |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + if (isset($this->session->data['payment_address']['custom_field'])) { |
|
| 167 | + $address_custom_field = $this->session->data['payment_address']['custom_field']; |
|
| 168 | + } else { |
|
| 169 | + $address_custom_field = array(); |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + $data['guest_custom_field'] = $guest_custom_field + $address_custom_field; |
|
| 173 | + } else { |
|
| 174 | + $data['guest_custom_field'] = array(); |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + $data['shipping_required'] = $this->cart->hasShipping(); |
|
| 178 | + |
|
| 179 | + if (isset($this->session->data['guest']['shipping_address'])) { |
|
| 180 | + $data['shipping_address'] = $this->session->data['guest']['shipping_address']; |
|
| 181 | + } else { |
|
| 182 | + $data['shipping_address'] = true; |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + $this->response->setOutput($this->load->view('checkout/guest', $data)); |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + public function save() { |
|
| 189 | + $this->load->language('checkout/checkout'); |
|
| 190 | + |
|
| 191 | + $json = array(); |
|
| 192 | + |
|
| 193 | + // Validate if customer is logged in. |
|
| 194 | + if ($this->customer->isLogged()) { |
|
| 195 | + $json['redirect'] = $this->url->link('checkout/checkout', '', true); |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + // Validate cart has products and has stock. |
|
| 199 | + if ((!$this->cart->hasProducts()) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { |
|
| 200 | + $json['redirect'] = $this->url->link('checkout/cart'); |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + // Check if guest checkout is available. |
|
| 204 | + if (!$this->config->get('config_checkout_guest') || $this->config->get('config_customer_price') || $this->cart->hasDownload()) { |
|
| 205 | + $json['redirect'] = $this->url->link('checkout/checkout', '', true); |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + if (!$json) { |
|
| 209 | + if ((\voku\helper\UTF8::strlen(trim($this->request->post['firstname'])) < 1) || (\voku\helper\UTF8::strlen(trim($this->request->post['firstname'])) > 32)) { |
|
| 210 | + $json['error']['firstname'] = $this->language->get('error_firstname'); |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + if ((\voku\helper\UTF8::strlen(trim($this->request->post['lastname'])) < 1) || (\voku\helper\UTF8::strlen(trim($this->request->post['lastname'])) > 32)) { |
|
| 214 | + $json['error']['lastname'] = $this->language->get('error_lastname'); |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + if ((\voku\helper\UTF8::strlen($this->request->post['email']) > 96) || !filter_var($this->request->post['email'], FILTER_VALIDATE_EMAIL)) { |
|
| 218 | + $json['error']['email'] = $this->language->get('error_email'); |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + if ((\voku\helper\UTF8::strlen($this->request->post['telephone']) < 3) || (\voku\helper\UTF8::strlen($this->request->post['telephone']) > 32)) { |
|
| 222 | + $json['error']['telephone'] = $this->language->get('error_telephone'); |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + if ((\voku\helper\UTF8::strlen(trim($this->request->post['address_1'])) < 3) || (\voku\helper\UTF8::strlen(trim($this->request->post['address_1'])) > 128)) { |
|
| 226 | + $json['error']['address_1'] = $this->language->get('error_address_1'); |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + if ((\voku\helper\UTF8::strlen(trim($this->request->post['city'])) < 2) || (\voku\helper\UTF8::strlen(trim($this->request->post['city'])) > 128)) { |
|
| 230 | + $json['error']['city'] = $this->language->get('error_city'); |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + $this->load->model('localisation/country'); |
|
| 234 | + |
|
| 235 | + $country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']); |
|
| 236 | + |
|
| 237 | + if ($country_info && $country_info['postcode_required'] && (\voku\helper\UTF8::strlen(trim($this->request->post['postcode'])) < 2 || \voku\helper\UTF8::strlen(trim($this->request->post['postcode'])) > 10)) { |
|
| 238 | + $json['error']['postcode'] = $this->language->get('error_postcode'); |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | - if ($this->request->post['country_id'] == '') { |
|
| 242 | - $json['error']['country'] = $this->language->get('error_country'); |
|
| 243 | - } |
|
| 241 | + if ($this->request->post['country_id'] == '') { |
|
| 242 | + $json['error']['country'] = $this->language->get('error_country'); |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | - if (!isset($this->request->post['zone_id']) || $this->request->post['zone_id'] == '' || !is_numeric($this->request->post['zone_id'])) { |
|
| 246 | - $json['error']['zone'] = $this->language->get('error_zone'); |
|
| 247 | - } |
|
| 245 | + if (!isset($this->request->post['zone_id']) || $this->request->post['zone_id'] == '' || !is_numeric($this->request->post['zone_id'])) { |
|
| 246 | + $json['error']['zone'] = $this->language->get('error_zone'); |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | - // Customer Group |
|
| 250 | - if (isset($this->request->post['customer_group_id']) && is_array($this->config->get('config_customer_group_display')) && in_array($this->request->post['customer_group_id'], $this->config->get('config_customer_group_display'))) { |
|
| 251 | - $customer_group_id = $this->request->post['customer_group_id']; |
|
| 252 | - } else { |
|
| 253 | - $customer_group_id = $this->config->get('config_customer_group_id'); |
|
| 254 | - } |
|
| 249 | + // Customer Group |
|
| 250 | + if (isset($this->request->post['customer_group_id']) && is_array($this->config->get('config_customer_group_display')) && in_array($this->request->post['customer_group_id'], $this->config->get('config_customer_group_display'))) { |
|
| 251 | + $customer_group_id = $this->request->post['customer_group_id']; |
|
| 252 | + } else { |
|
| 253 | + $customer_group_id = $this->config->get('config_customer_group_id'); |
|
| 254 | + } |
|
| 255 | 255 | |
| 256 | - // Custom field validation |
|
| 257 | - $this->load->model('account/custom_field'); |
|
| 256 | + // Custom field validation |
|
| 257 | + $this->load->model('account/custom_field'); |
|
| 258 | 258 | |
| 259 | - $custom_fields = $this->model_account_custom_field->getCustomFields($customer_group_id); |
|
| 260 | - |
|
| 261 | - foreach ($custom_fields as $custom_field) { |
|
| 262 | - if ($custom_field['required'] && empty($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']])) { |
|
| 263 | - $json['error']['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']); |
|
| 264 | - } elseif (($custom_field['type'] == 'text') && !empty($custom_field['validation']) && !filter_var($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $custom_field['validation'])))) { |
|
| 259 | + $custom_fields = $this->model_account_custom_field->getCustomFields($customer_group_id); |
|
| 260 | + |
|
| 261 | + foreach ($custom_fields as $custom_field) { |
|
| 262 | + if ($custom_field['required'] && empty($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']])) { |
|
| 263 | + $json['error']['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']); |
|
| 264 | + } elseif (($custom_field['type'] == 'text') && !empty($custom_field['validation']) && !filter_var($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $custom_field['validation'])))) { |
|
| 265 | 265 | $json['error']['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']); |
| 266 | 266 | } |
| 267 | - } |
|
| 268 | - |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - if (!$json) { |
|
| 272 | - $this->session->data['account'] = 'guest'; |
|
| 273 | - |
|
| 274 | - $this->session->data['guest']['customer_group_id'] = $customer_group_id; |
|
| 275 | - $this->session->data['guest']['firstname'] = $this->request->post['firstname']; |
|
| 276 | - $this->session->data['guest']['lastname'] = $this->request->post['lastname']; |
|
| 277 | - $this->session->data['guest']['email'] = $this->request->post['email']; |
|
| 278 | - $this->session->data['guest']['telephone'] = $this->request->post['telephone']; |
|
| 279 | - $this->session->data['guest']['fax'] = $this->request->post['fax']; |
|
| 280 | - |
|
| 281 | - if (isset($this->request->post['custom_field']['account'])) { |
|
| 282 | - $this->session->data['guest']['custom_field'] = $this->request->post['custom_field']['account']; |
|
| 283 | - } else { |
|
| 284 | - $this->session->data['guest']['custom_field'] = array(); |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - $this->session->data['payment_address']['firstname'] = $this->request->post['firstname']; |
|
| 288 | - $this->session->data['payment_address']['lastname'] = $this->request->post['lastname']; |
|
| 289 | - $this->session->data['payment_address']['company'] = $this->request->post['company']; |
|
| 290 | - $this->session->data['payment_address']['address_1'] = $this->request->post['address_1']; |
|
| 291 | - $this->session->data['payment_address']['address_2'] = $this->request->post['address_2']; |
|
| 292 | - $this->session->data['payment_address']['postcode'] = $this->request->post['postcode']; |
|
| 293 | - $this->session->data['payment_address']['city'] = $this->request->post['city']; |
|
| 294 | - $this->session->data['payment_address']['country_id'] = $this->request->post['country_id']; |
|
| 295 | - $this->session->data['payment_address']['zone_id'] = $this->request->post['zone_id']; |
|
| 296 | - |
|
| 297 | - $this->load->model('localisation/country'); |
|
| 298 | - |
|
| 299 | - $country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']); |
|
| 300 | - |
|
| 301 | - if ($country_info) { |
|
| 302 | - $this->session->data['payment_address']['country'] = $country_info['name']; |
|
| 303 | - $this->session->data['payment_address']['iso_code_2'] = $country_info['iso_code_2']; |
|
| 304 | - $this->session->data['payment_address']['iso_code_3'] = $country_info['iso_code_3']; |
|
| 305 | - $this->session->data['payment_address']['address_format'] = $country_info['address_format']; |
|
| 306 | - } else { |
|
| 307 | - $this->session->data['payment_address']['country'] = ''; |
|
| 308 | - $this->session->data['payment_address']['iso_code_2'] = ''; |
|
| 309 | - $this->session->data['payment_address']['iso_code_3'] = ''; |
|
| 310 | - $this->session->data['payment_address']['address_format'] = ''; |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - if (isset($this->request->post['custom_field']['address'])) { |
|
| 314 | - $this->session->data['payment_address']['custom_field'] = $this->request->post['custom_field']['address']; |
|
| 315 | - } else { |
|
| 316 | - $this->session->data['payment_address']['custom_field'] = array(); |
|
| 317 | - } |
|
| 318 | - |
|
| 319 | - $this->load->model('localisation/zone'); |
|
| 320 | - |
|
| 321 | - $zone_info = $this->model_localisation_zone->getZone($this->request->post['zone_id']); |
|
| 322 | - |
|
| 323 | - if ($zone_info) { |
|
| 324 | - $this->session->data['payment_address']['zone'] = $zone_info['name']; |
|
| 325 | - $this->session->data['payment_address']['zone_code'] = $zone_info['code']; |
|
| 326 | - } else { |
|
| 327 | - $this->session->data['payment_address']['zone'] = ''; |
|
| 328 | - $this->session->data['payment_address']['zone_code'] = ''; |
|
| 329 | - } |
|
| 330 | - |
|
| 331 | - if (!empty($this->request->post['shipping_address'])) { |
|
| 332 | - $this->session->data['guest']['shipping_address'] = $this->request->post['shipping_address']; |
|
| 333 | - } else { |
|
| 334 | - $this->session->data['guest']['shipping_address'] = false; |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - if ($this->session->data['guest']['shipping_address']) { |
|
| 338 | - $this->session->data['shipping_address']['firstname'] = $this->request->post['firstname']; |
|
| 339 | - $this->session->data['shipping_address']['lastname'] = $this->request->post['lastname']; |
|
| 340 | - $this->session->data['shipping_address']['company'] = $this->request->post['company']; |
|
| 341 | - $this->session->data['shipping_address']['address_1'] = $this->request->post['address_1']; |
|
| 342 | - $this->session->data['shipping_address']['address_2'] = $this->request->post['address_2']; |
|
| 343 | - $this->session->data['shipping_address']['postcode'] = $this->request->post['postcode']; |
|
| 344 | - $this->session->data['shipping_address']['city'] = $this->request->post['city']; |
|
| 345 | - $this->session->data['shipping_address']['country_id'] = $this->request->post['country_id']; |
|
| 346 | - $this->session->data['shipping_address']['zone_id'] = $this->request->post['zone_id']; |
|
| 347 | - |
|
| 348 | - if ($country_info) { |
|
| 349 | - $this->session->data['shipping_address']['country'] = $country_info['name']; |
|
| 350 | - $this->session->data['shipping_address']['iso_code_2'] = $country_info['iso_code_2']; |
|
| 351 | - $this->session->data['shipping_address']['iso_code_3'] = $country_info['iso_code_3']; |
|
| 352 | - $this->session->data['shipping_address']['address_format'] = $country_info['address_format']; |
|
| 353 | - } else { |
|
| 354 | - $this->session->data['shipping_address']['country'] = ''; |
|
| 355 | - $this->session->data['shipping_address']['iso_code_2'] = ''; |
|
| 356 | - $this->session->data['shipping_address']['iso_code_3'] = ''; |
|
| 357 | - $this->session->data['shipping_address']['address_format'] = ''; |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - if ($zone_info) { |
|
| 361 | - $this->session->data['shipping_address']['zone'] = $zone_info['name']; |
|
| 362 | - $this->session->data['shipping_address']['zone_code'] = $zone_info['code']; |
|
| 363 | - } else { |
|
| 364 | - $this->session->data['shipping_address']['zone'] = ''; |
|
| 365 | - $this->session->data['shipping_address']['zone_code'] = ''; |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - if (isset($this->request->post['custom_field']['address'])) { |
|
| 369 | - $this->session->data['shipping_address']['custom_field'] = $this->request->post['custom_field']['address']; |
|
| 370 | - } else { |
|
| 371 | - $this->session->data['shipping_address']['custom_field'] = array(); |
|
| 372 | - } |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - unset($this->session->data['shipping_method']); |
|
| 376 | - unset($this->session->data['shipping_methods']); |
|
| 377 | - unset($this->session->data['payment_method']); |
|
| 378 | - unset($this->session->data['payment_methods']); |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - $this->response->addHeader('Content-Type: application/json'); |
|
| 382 | - $this->response->setOutput(json_encode($json)); |
|
| 383 | - } |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + if (!$json) { |
|
| 272 | + $this->session->data['account'] = 'guest'; |
|
| 273 | + |
|
| 274 | + $this->session->data['guest']['customer_group_id'] = $customer_group_id; |
|
| 275 | + $this->session->data['guest']['firstname'] = $this->request->post['firstname']; |
|
| 276 | + $this->session->data['guest']['lastname'] = $this->request->post['lastname']; |
|
| 277 | + $this->session->data['guest']['email'] = $this->request->post['email']; |
|
| 278 | + $this->session->data['guest']['telephone'] = $this->request->post['telephone']; |
|
| 279 | + $this->session->data['guest']['fax'] = $this->request->post['fax']; |
|
| 280 | + |
|
| 281 | + if (isset($this->request->post['custom_field']['account'])) { |
|
| 282 | + $this->session->data['guest']['custom_field'] = $this->request->post['custom_field']['account']; |
|
| 283 | + } else { |
|
| 284 | + $this->session->data['guest']['custom_field'] = array(); |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + $this->session->data['payment_address']['firstname'] = $this->request->post['firstname']; |
|
| 288 | + $this->session->data['payment_address']['lastname'] = $this->request->post['lastname']; |
|
| 289 | + $this->session->data['payment_address']['company'] = $this->request->post['company']; |
|
| 290 | + $this->session->data['payment_address']['address_1'] = $this->request->post['address_1']; |
|
| 291 | + $this->session->data['payment_address']['address_2'] = $this->request->post['address_2']; |
|
| 292 | + $this->session->data['payment_address']['postcode'] = $this->request->post['postcode']; |
|
| 293 | + $this->session->data['payment_address']['city'] = $this->request->post['city']; |
|
| 294 | + $this->session->data['payment_address']['country_id'] = $this->request->post['country_id']; |
|
| 295 | + $this->session->data['payment_address']['zone_id'] = $this->request->post['zone_id']; |
|
| 296 | + |
|
| 297 | + $this->load->model('localisation/country'); |
|
| 298 | + |
|
| 299 | + $country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']); |
|
| 300 | + |
|
| 301 | + if ($country_info) { |
|
| 302 | + $this->session->data['payment_address']['country'] = $country_info['name']; |
|
| 303 | + $this->session->data['payment_address']['iso_code_2'] = $country_info['iso_code_2']; |
|
| 304 | + $this->session->data['payment_address']['iso_code_3'] = $country_info['iso_code_3']; |
|
| 305 | + $this->session->data['payment_address']['address_format'] = $country_info['address_format']; |
|
| 306 | + } else { |
|
| 307 | + $this->session->data['payment_address']['country'] = ''; |
|
| 308 | + $this->session->data['payment_address']['iso_code_2'] = ''; |
|
| 309 | + $this->session->data['payment_address']['iso_code_3'] = ''; |
|
| 310 | + $this->session->data['payment_address']['address_format'] = ''; |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + if (isset($this->request->post['custom_field']['address'])) { |
|
| 314 | + $this->session->data['payment_address']['custom_field'] = $this->request->post['custom_field']['address']; |
|
| 315 | + } else { |
|
| 316 | + $this->session->data['payment_address']['custom_field'] = array(); |
|
| 317 | + } |
|
| 318 | + |
|
| 319 | + $this->load->model('localisation/zone'); |
|
| 320 | + |
|
| 321 | + $zone_info = $this->model_localisation_zone->getZone($this->request->post['zone_id']); |
|
| 322 | + |
|
| 323 | + if ($zone_info) { |
|
| 324 | + $this->session->data['payment_address']['zone'] = $zone_info['name']; |
|
| 325 | + $this->session->data['payment_address']['zone_code'] = $zone_info['code']; |
|
| 326 | + } else { |
|
| 327 | + $this->session->data['payment_address']['zone'] = ''; |
|
| 328 | + $this->session->data['payment_address']['zone_code'] = ''; |
|
| 329 | + } |
|
| 330 | + |
|
| 331 | + if (!empty($this->request->post['shipping_address'])) { |
|
| 332 | + $this->session->data['guest']['shipping_address'] = $this->request->post['shipping_address']; |
|
| 333 | + } else { |
|
| 334 | + $this->session->data['guest']['shipping_address'] = false; |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + if ($this->session->data['guest']['shipping_address']) { |
|
| 338 | + $this->session->data['shipping_address']['firstname'] = $this->request->post['firstname']; |
|
| 339 | + $this->session->data['shipping_address']['lastname'] = $this->request->post['lastname']; |
|
| 340 | + $this->session->data['shipping_address']['company'] = $this->request->post['company']; |
|
| 341 | + $this->session->data['shipping_address']['address_1'] = $this->request->post['address_1']; |
|
| 342 | + $this->session->data['shipping_address']['address_2'] = $this->request->post['address_2']; |
|
| 343 | + $this->session->data['shipping_address']['postcode'] = $this->request->post['postcode']; |
|
| 344 | + $this->session->data['shipping_address']['city'] = $this->request->post['city']; |
|
| 345 | + $this->session->data['shipping_address']['country_id'] = $this->request->post['country_id']; |
|
| 346 | + $this->session->data['shipping_address']['zone_id'] = $this->request->post['zone_id']; |
|
| 347 | + |
|
| 348 | + if ($country_info) { |
|
| 349 | + $this->session->data['shipping_address']['country'] = $country_info['name']; |
|
| 350 | + $this->session->data['shipping_address']['iso_code_2'] = $country_info['iso_code_2']; |
|
| 351 | + $this->session->data['shipping_address']['iso_code_3'] = $country_info['iso_code_3']; |
|
| 352 | + $this->session->data['shipping_address']['address_format'] = $country_info['address_format']; |
|
| 353 | + } else { |
|
| 354 | + $this->session->data['shipping_address']['country'] = ''; |
|
| 355 | + $this->session->data['shipping_address']['iso_code_2'] = ''; |
|
| 356 | + $this->session->data['shipping_address']['iso_code_3'] = ''; |
|
| 357 | + $this->session->data['shipping_address']['address_format'] = ''; |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + if ($zone_info) { |
|
| 361 | + $this->session->data['shipping_address']['zone'] = $zone_info['name']; |
|
| 362 | + $this->session->data['shipping_address']['zone_code'] = $zone_info['code']; |
|
| 363 | + } else { |
|
| 364 | + $this->session->data['shipping_address']['zone'] = ''; |
|
| 365 | + $this->session->data['shipping_address']['zone_code'] = ''; |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + if (isset($this->request->post['custom_field']['address'])) { |
|
| 369 | + $this->session->data['shipping_address']['custom_field'] = $this->request->post['custom_field']['address']; |
|
| 370 | + } else { |
|
| 371 | + $this->session->data['shipping_address']['custom_field'] = array(); |
|
| 372 | + } |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + unset($this->session->data['shipping_method']); |
|
| 376 | + unset($this->session->data['shipping_methods']); |
|
| 377 | + unset($this->session->data['payment_method']); |
|
| 378 | + unset($this->session->data['payment_methods']); |
|
| 379 | + } |
|
| 380 | + |
|
| 381 | + $this->response->addHeader('Content-Type: application/json'); |
|
| 382 | + $this->response->setOutput(json_encode($json)); |
|
| 383 | + } |
|
| 384 | 384 | } |
@@ -21,183 +21,183 @@ |
||
| 21 | 21 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
| 22 | 22 | |
| 23 | 23 | class ControllerCheckoutPaymentAddress extends \Sunrise\Engine\Core\Controller { |
| 24 | - public function index() { |
|
| 25 | - $this->load->language('checkout/checkout'); |
|
| 24 | + public function index() { |
|
| 25 | + $this->load->language('checkout/checkout'); |
|
| 26 | 26 | |
| 27 | - $data['text_address_existing'] = $this->language->get('text_address_existing'); |
|
| 28 | - $data['text_address_new'] = $this->language->get('text_address_new'); |
|
| 29 | - $data['text_select'] = $this->language->get('text_select'); |
|
| 30 | - $data['text_none'] = $this->language->get('text_none'); |
|
| 31 | - $data['text_loading'] = $this->language->get('text_loading'); |
|
| 32 | - |
|
| 33 | - $data['entry_firstname'] = $this->language->get('entry_firstname'); |
|
| 34 | - $data['entry_lastname'] = $this->language->get('entry_lastname'); |
|
| 35 | - $data['entry_company'] = $this->language->get('entry_company'); |
|
| 36 | - $data['entry_address_1'] = $this->language->get('entry_address_1'); |
|
| 37 | - $data['entry_address_2'] = $this->language->get('entry_address_2'); |
|
| 38 | - $data['entry_postcode'] = $this->language->get('entry_postcode'); |
|
| 39 | - $data['entry_city'] = $this->language->get('entry_city'); |
|
| 40 | - $data['entry_country'] = $this->language->get('entry_country'); |
|
| 41 | - $data['entry_zone'] = $this->language->get('entry_zone'); |
|
| 42 | - |
|
| 43 | - $data['button_continue'] = $this->language->get('button_continue'); |
|
| 44 | - $data['button_upload'] = $this->language->get('button_upload'); |
|
| 45 | - |
|
| 46 | - if (isset($this->session->data['payment_address']['address_id'])) { |
|
| 47 | - $data['address_id'] = $this->session->data['payment_address']['address_id']; |
|
| 48 | - } else { |
|
| 49 | - $data['address_id'] = $this->customer->getAddressId(); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - $this->load->model('account/address'); |
|
| 53 | - |
|
| 54 | - $data['addresses'] = $this->model_account_address->getAddresses(); |
|
| 55 | - |
|
| 56 | - if (isset($this->session->data['payment_address']['country_id'])) { |
|
| 57 | - $data['country_id'] = $this->session->data['payment_address']['country_id']; |
|
| 58 | - } else { |
|
| 59 | - $data['country_id'] = $this->config->get('config_country_id'); |
|
| 60 | - } |
|
| 27 | + $data['text_address_existing'] = $this->language->get('text_address_existing'); |
|
| 28 | + $data['text_address_new'] = $this->language->get('text_address_new'); |
|
| 29 | + $data['text_select'] = $this->language->get('text_select'); |
|
| 30 | + $data['text_none'] = $this->language->get('text_none'); |
|
| 31 | + $data['text_loading'] = $this->language->get('text_loading'); |
|
| 32 | + |
|
| 33 | + $data['entry_firstname'] = $this->language->get('entry_firstname'); |
|
| 34 | + $data['entry_lastname'] = $this->language->get('entry_lastname'); |
|
| 35 | + $data['entry_company'] = $this->language->get('entry_company'); |
|
| 36 | + $data['entry_address_1'] = $this->language->get('entry_address_1'); |
|
| 37 | + $data['entry_address_2'] = $this->language->get('entry_address_2'); |
|
| 38 | + $data['entry_postcode'] = $this->language->get('entry_postcode'); |
|
| 39 | + $data['entry_city'] = $this->language->get('entry_city'); |
|
| 40 | + $data['entry_country'] = $this->language->get('entry_country'); |
|
| 41 | + $data['entry_zone'] = $this->language->get('entry_zone'); |
|
| 42 | + |
|
| 43 | + $data['button_continue'] = $this->language->get('button_continue'); |
|
| 44 | + $data['button_upload'] = $this->language->get('button_upload'); |
|
| 45 | + |
|
| 46 | + if (isset($this->session->data['payment_address']['address_id'])) { |
|
| 47 | + $data['address_id'] = $this->session->data['payment_address']['address_id']; |
|
| 48 | + } else { |
|
| 49 | + $data['address_id'] = $this->customer->getAddressId(); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + $this->load->model('account/address'); |
|
| 53 | + |
|
| 54 | + $data['addresses'] = $this->model_account_address->getAddresses(); |
|
| 55 | + |
|
| 56 | + if (isset($this->session->data['payment_address']['country_id'])) { |
|
| 57 | + $data['country_id'] = $this->session->data['payment_address']['country_id']; |
|
| 58 | + } else { |
|
| 59 | + $data['country_id'] = $this->config->get('config_country_id'); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - if (isset($this->session->data['payment_address']['zone_id'])) { |
|
| 63 | - $data['zone_id'] = $this->session->data['payment_address']['zone_id']; |
|
| 64 | - } else { |
|
| 65 | - $data['zone_id'] = ''; |
|
| 66 | - } |
|
| 62 | + if (isset($this->session->data['payment_address']['zone_id'])) { |
|
| 63 | + $data['zone_id'] = $this->session->data['payment_address']['zone_id']; |
|
| 64 | + } else { |
|
| 65 | + $data['zone_id'] = ''; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - $this->load->model('localisation/country'); |
|
| 68 | + $this->load->model('localisation/country'); |
|
| 69 | 69 | |
| 70 | - $data['countries'] = $this->model_localisation_country->getCountries(); |
|
| 70 | + $data['countries'] = $this->model_localisation_country->getCountries(); |
|
| 71 | 71 | |
| 72 | - // Custom Fields |
|
| 73 | - $this->load->model('account/custom_field'); |
|
| 72 | + // Custom Fields |
|
| 73 | + $this->load->model('account/custom_field'); |
|
| 74 | 74 | |
| 75 | - $data['custom_fields'] = $this->model_account_custom_field->getCustomFields($this->config->get('config_customer_group_id')); |
|
| 75 | + $data['custom_fields'] = $this->model_account_custom_field->getCustomFields($this->config->get('config_customer_group_id')); |
|
| 76 | 76 | |
| 77 | - if (isset($this->session->data['payment_address']['custom_field'])) { |
|
| 78 | - $data['payment_address_custom_field'] = $this->session->data['payment_address']['custom_field']; |
|
| 79 | - } else { |
|
| 80 | - $data['payment_address_custom_field'] = array(); |
|
| 81 | - } |
|
| 77 | + if (isset($this->session->data['payment_address']['custom_field'])) { |
|
| 78 | + $data['payment_address_custom_field'] = $this->session->data['payment_address']['custom_field']; |
|
| 79 | + } else { |
|
| 80 | + $data['payment_address_custom_field'] = array(); |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - $this->response->setOutput($this->load->view('checkout/payment_address', $data)); |
|
| 84 | - } |
|
| 83 | + $this->response->setOutput($this->load->view('checkout/payment_address', $data)); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - public function save() { |
|
| 87 | - $this->load->language('checkout/checkout'); |
|
| 86 | + public function save() { |
|
| 87 | + $this->load->language('checkout/checkout'); |
|
| 88 | 88 | |
| 89 | - $json = array(); |
|
| 89 | + $json = array(); |
|
| 90 | 90 | |
| 91 | - // Validate if customer is logged in. |
|
| 92 | - if (!$this->customer->isLogged()) { |
|
| 93 | - $json['redirect'] = $this->url->link('checkout/checkout', '', true); |
|
| 94 | - } |
|
| 91 | + // Validate if customer is logged in. |
|
| 92 | + if (!$this->customer->isLogged()) { |
|
| 93 | + $json['redirect'] = $this->url->link('checkout/checkout', '', true); |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - // Validate cart has products and has stock. |
|
| 97 | - if ((!$this->cart->hasProducts()) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { |
|
| 98 | - $json['redirect'] = $this->url->link('checkout/cart'); |
|
| 99 | - } |
|
| 96 | + // Validate cart has products and has stock. |
|
| 97 | + if ((!$this->cart->hasProducts()) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { |
|
| 98 | + $json['redirect'] = $this->url->link('checkout/cart'); |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - // Validate minimum quantity requirements. |
|
| 102 | - $products = $this->cart->getProducts(); |
|
| 101 | + // Validate minimum quantity requirements. |
|
| 102 | + $products = $this->cart->getProducts(); |
|
| 103 | 103 | |
| 104 | - foreach ($products as $product) { |
|
| 105 | - $product_total = 0; |
|
| 104 | + foreach ($products as $product) { |
|
| 105 | + $product_total = 0; |
|
| 106 | 106 | |
| 107 | - foreach ($products as $product_2) { |
|
| 108 | - if ($product_2['product_id'] == $product['product_id']) { |
|
| 109 | - $product_total += $product_2['quantity']; |
|
| 110 | - } |
|
| 111 | - } |
|
| 107 | + foreach ($products as $product_2) { |
|
| 108 | + if ($product_2['product_id'] == $product['product_id']) { |
|
| 109 | + $product_total += $product_2['quantity']; |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - if ($product['minimum'] > $product_total) { |
|
| 114 | - $json['redirect'] = $this->url->link('checkout/cart'); |
|
| 113 | + if ($product['minimum'] > $product_total) { |
|
| 114 | + $json['redirect'] = $this->url->link('checkout/cart'); |
|
| 115 | 115 | |
| 116 | - break; |
|
| 117 | - } |
|
| 118 | - } |
|
| 116 | + break; |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - if (!$json) { |
|
| 121 | - if (isset($this->request->post['payment_address']) && $this->request->post['payment_address'] == 'existing') { |
|
| 122 | - $this->load->model('account/address'); |
|
| 120 | + if (!$json) { |
|
| 121 | + if (isset($this->request->post['payment_address']) && $this->request->post['payment_address'] == 'existing') { |
|
| 122 | + $this->load->model('account/address'); |
|
| 123 | 123 | |
| 124 | - if (empty($this->request->post['address_id'])) { |
|
| 125 | - $json['error']['warning'] = $this->language->get('error_address'); |
|
| 126 | - } elseif (!in_array($this->request->post['address_id'], array_keys($this->model_account_address->getAddresses()))) { |
|
| 127 | - $json['error']['warning'] = $this->language->get('error_address'); |
|
| 128 | - } |
|
| 124 | + if (empty($this->request->post['address_id'])) { |
|
| 125 | + $json['error']['warning'] = $this->language->get('error_address'); |
|
| 126 | + } elseif (!in_array($this->request->post['address_id'], array_keys($this->model_account_address->getAddresses()))) { |
|
| 127 | + $json['error']['warning'] = $this->language->get('error_address'); |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - if (!$json) { |
|
| 131 | - // Default Payment Address |
|
| 132 | - $this->load->model('account/address'); |
|
| 130 | + if (!$json) { |
|
| 131 | + // Default Payment Address |
|
| 132 | + $this->load->model('account/address'); |
|
| 133 | 133 | |
| 134 | - $this->session->data['payment_address'] = $this->model_account_address->getAddress($this->request->post['address_id']); |
|
| 134 | + $this->session->data['payment_address'] = $this->model_account_address->getAddress($this->request->post['address_id']); |
|
| 135 | 135 | |
| 136 | - unset($this->session->data['payment_method']); |
|
| 137 | - unset($this->session->data['payment_methods']); |
|
| 138 | - } |
|
| 139 | - } else { |
|
| 140 | - if ((\voku\helper\UTF8::strlen(trim($this->request->post['firstname'])) < 1) || (\voku\helper\UTF8::strlen(trim($this->request->post['firstname'])) > 32)) { |
|
| 141 | - $json['error']['firstname'] = $this->language->get('error_firstname'); |
|
| 142 | - } |
|
| 136 | + unset($this->session->data['payment_method']); |
|
| 137 | + unset($this->session->data['payment_methods']); |
|
| 138 | + } |
|
| 139 | + } else { |
|
| 140 | + if ((\voku\helper\UTF8::strlen(trim($this->request->post['firstname'])) < 1) || (\voku\helper\UTF8::strlen(trim($this->request->post['firstname'])) > 32)) { |
|
| 141 | + $json['error']['firstname'] = $this->language->get('error_firstname'); |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - if ((\voku\helper\UTF8::strlen(trim($this->request->post['lastname'])) < 1) || (\voku\helper\UTF8::strlen(trim($this->request->post['lastname'])) > 32)) { |
|
| 145 | - $json['error']['lastname'] = $this->language->get('error_lastname'); |
|
| 146 | - } |
|
| 144 | + if ((\voku\helper\UTF8::strlen(trim($this->request->post['lastname'])) < 1) || (\voku\helper\UTF8::strlen(trim($this->request->post['lastname'])) > 32)) { |
|
| 145 | + $json['error']['lastname'] = $this->language->get('error_lastname'); |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - if ((\voku\helper\UTF8::strlen(trim($this->request->post['address_1'])) < 3) || (\voku\helper\UTF8::strlen(trim($this->request->post['address_1'])) > 128)) { |
|
| 149 | - $json['error']['address_1'] = $this->language->get('error_address_1'); |
|
| 150 | - } |
|
| 148 | + if ((\voku\helper\UTF8::strlen(trim($this->request->post['address_1'])) < 3) || (\voku\helper\UTF8::strlen(trim($this->request->post['address_1'])) > 128)) { |
|
| 149 | + $json['error']['address_1'] = $this->language->get('error_address_1'); |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - if ((\voku\helper\UTF8::strlen($this->request->post['city']) < 2) || (\voku\helper\UTF8::strlen($this->request->post['city']) > 32)) { |
|
| 153 | - $json['error']['city'] = $this->language->get('error_city'); |
|
| 154 | - } |
|
| 152 | + if ((\voku\helper\UTF8::strlen($this->request->post['city']) < 2) || (\voku\helper\UTF8::strlen($this->request->post['city']) > 32)) { |
|
| 153 | + $json['error']['city'] = $this->language->get('error_city'); |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - $this->load->model('localisation/country'); |
|
| 156 | + $this->load->model('localisation/country'); |
|
| 157 | 157 | |
| 158 | - $country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']); |
|
| 158 | + $country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']); |
|
| 159 | 159 | |
| 160 | - if ($country_info && $country_info['postcode_required'] && (\voku\helper\UTF8::strlen(trim($this->request->post['postcode'])) < 2 || \voku\helper\UTF8::strlen(trim($this->request->post['postcode'])) > 10)) { |
|
| 161 | - $json['error']['postcode'] = $this->language->get('error_postcode'); |
|
| 162 | - } |
|
| 160 | + if ($country_info && $country_info['postcode_required'] && (\voku\helper\UTF8::strlen(trim($this->request->post['postcode'])) < 2 || \voku\helper\UTF8::strlen(trim($this->request->post['postcode'])) > 10)) { |
|
| 161 | + $json['error']['postcode'] = $this->language->get('error_postcode'); |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | - if ($this->request->post['country_id'] == '') { |
|
| 165 | - $json['error']['country'] = $this->language->get('error_country'); |
|
| 166 | - } |
|
| 164 | + if ($this->request->post['country_id'] == '') { |
|
| 165 | + $json['error']['country'] = $this->language->get('error_country'); |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - if (!isset($this->request->post['zone_id']) || $this->request->post['zone_id'] == '' || !is_numeric($this->request->post['zone_id'])) { |
|
| 169 | - $json['error']['zone'] = $this->language->get('error_zone'); |
|
| 170 | - } |
|
| 168 | + if (!isset($this->request->post['zone_id']) || $this->request->post['zone_id'] == '' || !is_numeric($this->request->post['zone_id'])) { |
|
| 169 | + $json['error']['zone'] = $this->language->get('error_zone'); |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | - // Custom field validation |
|
| 173 | - $this->load->model('account/custom_field'); |
|
| 172 | + // Custom field validation |
|
| 173 | + $this->load->model('account/custom_field'); |
|
| 174 | 174 | |
| 175 | - $custom_fields = $this->model_account_custom_field->getCustomFields($this->config->get('config_customer_group_id')); |
|
| 175 | + $custom_fields = $this->model_account_custom_field->getCustomFields($this->config->get('config_customer_group_id')); |
|
| 176 | 176 | |
| 177 | - foreach ($custom_fields as $custom_field) { |
|
| 178 | - if (($custom_field['location'] == 'address') && $custom_field['required'] && empty($this->request->post['custom_field'][$custom_field['custom_field_id']])) { |
|
| 179 | - $json['error']['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']); |
|
| 180 | - } elseif (($custom_field['location'] == 'address') && ($custom_field['type'] == 'text') && !empty($custom_field['validation']) && !filter_var($this->request->post['custom_field'][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $custom_field['validation'])))) { |
|
| 177 | + foreach ($custom_fields as $custom_field) { |
|
| 178 | + if (($custom_field['location'] == 'address') && $custom_field['required'] && empty($this->request->post['custom_field'][$custom_field['custom_field_id']])) { |
|
| 179 | + $json['error']['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']); |
|
| 180 | + } elseif (($custom_field['location'] == 'address') && ($custom_field['type'] == 'text') && !empty($custom_field['validation']) && !filter_var($this->request->post['custom_field'][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $custom_field['validation'])))) { |
|
| 181 | 181 | $json['error']['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']); |
| 182 | 182 | } |
| 183 | - } |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - if (!$json) { |
|
| 186 | - // Default Payment Address |
|
| 187 | - $this->load->model('account/address'); |
|
| 185 | + if (!$json) { |
|
| 186 | + // Default Payment Address |
|
| 187 | + $this->load->model('account/address'); |
|
| 188 | 188 | |
| 189 | - $address_id = $this->model_account_address->addAddress($this->request->post); |
|
| 189 | + $address_id = $this->model_account_address->addAddress($this->request->post); |
|
| 190 | 190 | |
| 191 | - $this->session->data['payment_address'] = $this->model_account_address->getAddress($address_id); |
|
| 191 | + $this->session->data['payment_address'] = $this->model_account_address->getAddress($address_id); |
|
| 192 | 192 | |
| 193 | - unset($this->session->data['payment_method']); |
|
| 194 | - unset($this->session->data['payment_methods']); |
|
| 193 | + unset($this->session->data['payment_method']); |
|
| 194 | + unset($this->session->data['payment_methods']); |
|
| 195 | 195 | |
| 196 | - } |
|
| 197 | - } |
|
| 198 | - } |
|
| 196 | + } |
|
| 197 | + } |
|
| 198 | + } |
|
| 199 | 199 | |
| 200 | - $this->response->addHeader('Content-Type: application/json'); |
|
| 201 | - $this->response->setOutput(json_encode($json)); |
|
| 202 | - } |
|
| 200 | + $this->response->addHeader('Content-Type: application/json'); |
|
| 201 | + $this->response->setOutput(json_encode($json)); |
|
| 202 | + } |
|
| 203 | 203 | } |
| 204 | 204 | \ No newline at end of file |
@@ -21,183 +21,183 @@ |
||
| 21 | 21 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
| 22 | 22 | |
| 23 | 23 | class ControllerCheckoutPaymentMethod extends \Sunrise\Engine\Core\Controller { |
| 24 | - public function index() { |
|
| 25 | - $this->load->language('checkout/checkout'); |
|
| 26 | - |
|
| 27 | - if (isset($this->session->data['payment_address'])) { |
|
| 28 | - // Totals |
|
| 29 | - $totals = array(); |
|
| 30 | - $total = 0; |
|
| 31 | - |
|
| 32 | - // Because __call can not keep var references so we put them into an array. |
|
| 33 | - $total_data = array( |
|
| 34 | - 'totals' => &$totals, |
|
| 35 | - 'total' => &$total |
|
| 36 | - ); |
|
| 24 | + public function index() { |
|
| 25 | + $this->load->language('checkout/checkout'); |
|
| 26 | + |
|
| 27 | + if (isset($this->session->data['payment_address'])) { |
|
| 28 | + // Totals |
|
| 29 | + $totals = array(); |
|
| 30 | + $total = 0; |
|
| 31 | + |
|
| 32 | + // Because __call can not keep var references so we put them into an array. |
|
| 33 | + $total_data = array( |
|
| 34 | + 'totals' => &$totals, |
|
| 35 | + 'total' => &$total |
|
| 36 | + ); |
|
| 37 | 37 | |
| 38 | - $this->load->model('extension/extension'); |
|
| 38 | + $this->load->model('extension/extension'); |
|
| 39 | 39 | |
| 40 | - $sort_order = array(); |
|
| 40 | + $sort_order = array(); |
|
| 41 | 41 | |
| 42 | - $results = $this->model_extension_extension->getExtensions('total'); |
|
| 42 | + $results = $this->model_extension_extension->getExtensions('total'); |
|
| 43 | 43 | |
| 44 | - foreach ($results as $key => $value) { |
|
| 45 | - $sort_order[$key] = $this->config->get($value['code'] . '_sort_order'); |
|
| 46 | - } |
|
| 44 | + foreach ($results as $key => $value) { |
|
| 45 | + $sort_order[$key] = $this->config->get($value['code'] . '_sort_order'); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - array_multisort($sort_order, SORT_ASC, $results); |
|
| 48 | + array_multisort($sort_order, SORT_ASC, $results); |
|
| 49 | 49 | |
| 50 | - foreach ($results as $result) { |
|
| 51 | - if ($this->config->get($result['code'] . '_status')) { |
|
| 52 | - $this->load->model('extension/total/' . $result['code']); |
|
| 50 | + foreach ($results as $result) { |
|
| 51 | + if ($this->config->get($result['code'] . '_status')) { |
|
| 52 | + $this->load->model('extension/total/' . $result['code']); |
|
| 53 | 53 | |
| 54 | - // We have to put the totals in an array so that they pass by reference. |
|
| 55 | - $this->{'model_extension_total_' . $result['code']}->getTotal($total_data); |
|
| 56 | - } |
|
| 57 | - } |
|
| 54 | + // We have to put the totals in an array so that they pass by reference. |
|
| 55 | + $this->{'model_extension_total_' . $result['code']}->getTotal($total_data); |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - // Payment Methods |
|
| 60 | - $method_data = array(); |
|
| 59 | + // Payment Methods |
|
| 60 | + $method_data = array(); |
|
| 61 | 61 | |
| 62 | - $this->load->model('extension/extension'); |
|
| 62 | + $this->load->model('extension/extension'); |
|
| 63 | 63 | |
| 64 | - $results = $this->model_extension_extension->getExtensions('payment'); |
|
| 64 | + $results = $this->model_extension_extension->getExtensions('payment'); |
|
| 65 | 65 | |
| 66 | - foreach ($results as $result) { |
|
| 67 | - if ($this->config->get($result['code'] . '_status')) { |
|
| 68 | - $this->load->model('extension/payment/' . $result['code']); |
|
| 66 | + foreach ($results as $result) { |
|
| 67 | + if ($this->config->get($result['code'] . '_status')) { |
|
| 68 | + $this->load->model('extension/payment/' . $result['code']); |
|
| 69 | 69 | |
| 70 | - $method = $this->{'model_extension_payment_' . $result['code']}->getMethod($this->session->data['payment_address'], $total); |
|
| 70 | + $method = $this->{'model_extension_payment_' . $result['code']}->getMethod($this->session->data['payment_address'], $total); |
|
| 71 | 71 | |
| 72 | - if ($method) { |
|
| 73 | - $method_data[$result['code']] = $method; |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - } |
|
| 72 | + if ($method) { |
|
| 73 | + $method_data[$result['code']] = $method; |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - $sort_order = array(); |
|
| 78 | + $sort_order = array(); |
|
| 79 | 79 | |
| 80 | - foreach ($method_data as $key => $value) { |
|
| 81 | - $sort_order[$key] = $value['sort_order']; |
|
| 82 | - } |
|
| 80 | + foreach ($method_data as $key => $value) { |
|
| 81 | + $sort_order[$key] = $value['sort_order']; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - array_multisort($sort_order, SORT_ASC, $method_data); |
|
| 84 | + array_multisort($sort_order, SORT_ASC, $method_data); |
|
| 85 | 85 | |
| 86 | - $this->session->data['payment_methods'] = $method_data; |
|
| 87 | - } |
|
| 86 | + $this->session->data['payment_methods'] = $method_data; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - $data['text_payment_method'] = $this->language->get('text_payment_method'); |
|
| 90 | - $data['text_comments'] = $this->language->get('text_comments'); |
|
| 91 | - $data['text_loading'] = $this->language->get('text_loading'); |
|
| 89 | + $data['text_payment_method'] = $this->language->get('text_payment_method'); |
|
| 90 | + $data['text_comments'] = $this->language->get('text_comments'); |
|
| 91 | + $data['text_loading'] = $this->language->get('text_loading'); |
|
| 92 | 92 | |
| 93 | - $data['button_continue'] = $this->language->get('button_continue'); |
|
| 93 | + $data['button_continue'] = $this->language->get('button_continue'); |
|
| 94 | 94 | |
| 95 | - if (empty($this->session->data['payment_methods'])) { |
|
| 96 | - $data['error_warning'] = sprintf($this->language->get('error_no_payment'), $this->url->link('information/contact')); |
|
| 97 | - } else { |
|
| 98 | - $data['error_warning'] = ''; |
|
| 99 | - } |
|
| 95 | + if (empty($this->session->data['payment_methods'])) { |
|
| 96 | + $data['error_warning'] = sprintf($this->language->get('error_no_payment'), $this->url->link('information/contact')); |
|
| 97 | + } else { |
|
| 98 | + $data['error_warning'] = ''; |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - if (isset($this->session->data['payment_methods'])) { |
|
| 102 | - $data['payment_methods'] = $this->session->data['payment_methods']; |
|
| 103 | - } else { |
|
| 104 | - $data['payment_methods'] = array(); |
|
| 105 | - } |
|
| 101 | + if (isset($this->session->data['payment_methods'])) { |
|
| 102 | + $data['payment_methods'] = $this->session->data['payment_methods']; |
|
| 103 | + } else { |
|
| 104 | + $data['payment_methods'] = array(); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - if (isset($this->session->data['payment_method']['code'])) { |
|
| 108 | - $data['code'] = $this->session->data['payment_method']['code']; |
|
| 109 | - } else { |
|
| 110 | - $data['code'] = ''; |
|
| 111 | - } |
|
| 107 | + if (isset($this->session->data['payment_method']['code'])) { |
|
| 108 | + $data['code'] = $this->session->data['payment_method']['code']; |
|
| 109 | + } else { |
|
| 110 | + $data['code'] = ''; |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - if (isset($this->session->data['comment'])) { |
|
| 114 | - $data['comment'] = $this->session->data['comment']; |
|
| 115 | - } else { |
|
| 116 | - $data['comment'] = ''; |
|
| 117 | - } |
|
| 113 | + if (isset($this->session->data['comment'])) { |
|
| 114 | + $data['comment'] = $this->session->data['comment']; |
|
| 115 | + } else { |
|
| 116 | + $data['comment'] = ''; |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - $data['scripts'] = $this->document->getScripts(); |
|
| 119 | + $data['scripts'] = $this->document->getScripts(); |
|
| 120 | 120 | |
| 121 | - if ($this->config->get('config_checkout_id')) { |
|
| 122 | - $this->load->model('catalog/information'); |
|
| 121 | + if ($this->config->get('config_checkout_id')) { |
|
| 122 | + $this->load->model('catalog/information'); |
|
| 123 | 123 | |
| 124 | - $information_info = $this->model_catalog_information->getInformation($this->config->get('config_checkout_id')); |
|
| 124 | + $information_info = $this->model_catalog_information->getInformation($this->config->get('config_checkout_id')); |
|
| 125 | 125 | |
| 126 | - if ($information_info) { |
|
| 127 | - $data['text_agree'] = sprintf($this->language->get('text_agree'), $this->url->link('information/information/agree', 'information_id=' . $this->config->get('config_checkout_id'), true), $information_info['title'], $information_info['title']); |
|
| 128 | - } else { |
|
| 129 | - $data['text_agree'] = ''; |
|
| 130 | - } |
|
| 131 | - } else { |
|
| 132 | - $data['text_agree'] = ''; |
|
| 133 | - } |
|
| 126 | + if ($information_info) { |
|
| 127 | + $data['text_agree'] = sprintf($this->language->get('text_agree'), $this->url->link('information/information/agree', 'information_id=' . $this->config->get('config_checkout_id'), true), $information_info['title'], $information_info['title']); |
|
| 128 | + } else { |
|
| 129 | + $data['text_agree'] = ''; |
|
| 130 | + } |
|
| 131 | + } else { |
|
| 132 | + $data['text_agree'] = ''; |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - if (isset($this->session->data['agree'])) { |
|
| 136 | - $data['agree'] = $this->session->data['agree']; |
|
| 137 | - } else { |
|
| 138 | - $data['agree'] = ''; |
|
| 139 | - } |
|
| 135 | + if (isset($this->session->data['agree'])) { |
|
| 136 | + $data['agree'] = $this->session->data['agree']; |
|
| 137 | + } else { |
|
| 138 | + $data['agree'] = ''; |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | - $this->response->setOutput($this->load->view('checkout/payment_method', $data)); |
|
| 142 | - } |
|
| 141 | + $this->response->setOutput($this->load->view('checkout/payment_method', $data)); |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - public function save() { |
|
| 145 | - $this->load->language('checkout/checkout'); |
|
| 144 | + public function save() { |
|
| 145 | + $this->load->language('checkout/checkout'); |
|
| 146 | 146 | |
| 147 | - $json = array(); |
|
| 147 | + $json = array(); |
|
| 148 | 148 | |
| 149 | - // Validate if payment address has been set. |
|
| 150 | - if (!isset($this->session->data['payment_address'])) { |
|
| 151 | - $json['redirect'] = $this->url->link('checkout/checkout', '', true); |
|
| 152 | - } |
|
| 149 | + // Validate if payment address has been set. |
|
| 150 | + if (!isset($this->session->data['payment_address'])) { |
|
| 151 | + $json['redirect'] = $this->url->link('checkout/checkout', '', true); |
|
| 152 | + } |
|
| 153 | 153 | |
| 154 | - // Validate cart has products and has stock. |
|
| 155 | - if ((!$this->cart->hasProducts()) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { |
|
| 156 | - $json['redirect'] = $this->url->link('checkout/cart'); |
|
| 157 | - } |
|
| 154 | + // Validate cart has products and has stock. |
|
| 155 | + if ((!$this->cart->hasProducts()) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { |
|
| 156 | + $json['redirect'] = $this->url->link('checkout/cart'); |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - // Validate minimum quantity requirements. |
|
| 160 | - $products = $this->cart->getProducts(); |
|
| 159 | + // Validate minimum quantity requirements. |
|
| 160 | + $products = $this->cart->getProducts(); |
|
| 161 | 161 | |
| 162 | - foreach ($products as $product) { |
|
| 163 | - $product_total = 0; |
|
| 162 | + foreach ($products as $product) { |
|
| 163 | + $product_total = 0; |
|
| 164 | 164 | |
| 165 | - foreach ($products as $product_2) { |
|
| 166 | - if ($product_2['product_id'] == $product['product_id']) { |
|
| 167 | - $product_total += $product_2['quantity']; |
|
| 168 | - } |
|
| 169 | - } |
|
| 165 | + foreach ($products as $product_2) { |
|
| 166 | + if ($product_2['product_id'] == $product['product_id']) { |
|
| 167 | + $product_total += $product_2['quantity']; |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | 170 | |
| 171 | - if ($product['minimum'] > $product_total) { |
|
| 172 | - $json['redirect'] = $this->url->link('checkout/cart'); |
|
| 171 | + if ($product['minimum'] > $product_total) { |
|
| 172 | + $json['redirect'] = $this->url->link('checkout/cart'); |
|
| 173 | 173 | |
| 174 | - break; |
|
| 175 | - } |
|
| 176 | - } |
|
| 174 | + break; |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | 177 | |
| 178 | - if (!isset($this->request->post['payment_method'])) { |
|
| 179 | - $json['error']['warning'] = $this->language->get('error_payment'); |
|
| 180 | - } elseif (!isset($this->session->data['payment_methods'][$this->request->post['payment_method']])) { |
|
| 181 | - $json['error']['warning'] = $this->language->get('error_payment'); |
|
| 182 | - } |
|
| 178 | + if (!isset($this->request->post['payment_method'])) { |
|
| 179 | + $json['error']['warning'] = $this->language->get('error_payment'); |
|
| 180 | + } elseif (!isset($this->session->data['payment_methods'][$this->request->post['payment_method']])) { |
|
| 181 | + $json['error']['warning'] = $this->language->get('error_payment'); |
|
| 182 | + } |
|
| 183 | 183 | |
| 184 | - if ($this->config->get('config_checkout_id')) { |
|
| 185 | - $this->load->model('catalog/information'); |
|
| 186 | - |
|
| 187 | - $information_info = $this->model_catalog_information->getInformation($this->config->get('config_checkout_id')); |
|
| 184 | + if ($this->config->get('config_checkout_id')) { |
|
| 185 | + $this->load->model('catalog/information'); |
|
| 186 | + |
|
| 187 | + $information_info = $this->model_catalog_information->getInformation($this->config->get('config_checkout_id')); |
|
| 188 | 188 | |
| 189 | - if ($information_info && !isset($this->request->post['agree'])) { |
|
| 190 | - $json['error']['warning'] = sprintf($this->language->get('error_agree'), $information_info['title']); |
|
| 191 | - } |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - if (!$json) { |
|
| 195 | - $this->session->data['payment_method'] = $this->session->data['payment_methods'][$this->request->post['payment_method']]; |
|
| 196 | - |
|
| 197 | - $this->session->data['comment'] = strip_tags($this->request->post['comment']); |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - $this->response->addHeader('Content-Type: application/json'); |
|
| 201 | - $this->response->setOutput(json_encode($json)); |
|
| 202 | - } |
|
| 189 | + if ($information_info && !isset($this->request->post['agree'])) { |
|
| 190 | + $json['error']['warning'] = sprintf($this->language->get('error_agree'), $information_info['title']); |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + if (!$json) { |
|
| 195 | + $this->session->data['payment_method'] = $this->session->data['payment_methods'][$this->request->post['payment_method']]; |
|
| 196 | + |
|
| 197 | + $this->session->data['comment'] = strip_tags($this->request->post['comment']); |
|
| 198 | + } |
|
| 199 | + |
|
| 200 | + $this->response->addHeader('Content-Type: application/json'); |
|
| 201 | + $this->response->setOutput(json_encode($json)); |
|
| 202 | + } |
|
| 203 | 203 | } |
@@ -21,134 +21,134 @@ |
||
| 21 | 21 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
| 22 | 22 | |
| 23 | 23 | class ControllerCheckoutShippingMethod extends \Sunrise\Engine\Core\Controller { |
| 24 | - public function index() { |
|
| 25 | - $this->load->language('checkout/checkout'); |
|
| 24 | + public function index() { |
|
| 25 | + $this->load->language('checkout/checkout'); |
|
| 26 | 26 | |
| 27 | - if (isset($this->session->data['shipping_address'])) { |
|
| 28 | - // Shipping Methods |
|
| 29 | - $method_data = array(); |
|
| 27 | + if (isset($this->session->data['shipping_address'])) { |
|
| 28 | + // Shipping Methods |
|
| 29 | + $method_data = array(); |
|
| 30 | 30 | |
| 31 | - $this->load->model('extension/extension'); |
|
| 31 | + $this->load->model('extension/extension'); |
|
| 32 | 32 | |
| 33 | - $results = $this->model_extension_extension->getExtensions('shipping'); |
|
| 33 | + $results = $this->model_extension_extension->getExtensions('shipping'); |
|
| 34 | 34 | |
| 35 | - foreach ($results as $result) { |
|
| 36 | - if ($this->config->get($result['code'] . '_status')) { |
|
| 37 | - $this->load->model('extension/shipping/' . $result['code']); |
|
| 35 | + foreach ($results as $result) { |
|
| 36 | + if ($this->config->get($result['code'] . '_status')) { |
|
| 37 | + $this->load->model('extension/shipping/' . $result['code']); |
|
| 38 | 38 | |
| 39 | - $quote = $this->{'model_extension_shipping_' . $result['code']}->getQuote($this->session->data['shipping_address']); |
|
| 39 | + $quote = $this->{'model_extension_shipping_' . $result['code']}->getQuote($this->session->data['shipping_address']); |
|
| 40 | 40 | |
| 41 | - if ($quote) { |
|
| 42 | - $method_data[$result['code']] = array( |
|
| 43 | - 'title' => $quote['title'], |
|
| 44 | - 'quote' => $quote['quote'], |
|
| 45 | - 'sort_order' => $quote['sort_order'], |
|
| 46 | - 'error' => $quote['error'] |
|
| 47 | - ); |
|
| 48 | - } |
|
| 49 | - } |
|
| 50 | - } |
|
| 41 | + if ($quote) { |
|
| 42 | + $method_data[$result['code']] = array( |
|
| 43 | + 'title' => $quote['title'], |
|
| 44 | + 'quote' => $quote['quote'], |
|
| 45 | + 'sort_order' => $quote['sort_order'], |
|
| 46 | + 'error' => $quote['error'] |
|
| 47 | + ); |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - $sort_order = array(); |
|
| 52 | + $sort_order = array(); |
|
| 53 | 53 | |
| 54 | - foreach ($method_data as $key => $value) { |
|
| 55 | - $sort_order[$key] = $value['sort_order']; |
|
| 56 | - } |
|
| 54 | + foreach ($method_data as $key => $value) { |
|
| 55 | + $sort_order[$key] = $value['sort_order']; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - array_multisort($sort_order, SORT_ASC, $method_data); |
|
| 58 | + array_multisort($sort_order, SORT_ASC, $method_data); |
|
| 59 | 59 | |
| 60 | - $this->session->data['shipping_methods'] = $method_data; |
|
| 61 | - } |
|
| 60 | + $this->session->data['shipping_methods'] = $method_data; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - $data['text_shipping_method'] = $this->language->get('text_shipping_method'); |
|
| 64 | - $data['text_comments'] = $this->language->get('text_comments'); |
|
| 65 | - $data['text_loading'] = $this->language->get('text_loading'); |
|
| 63 | + $data['text_shipping_method'] = $this->language->get('text_shipping_method'); |
|
| 64 | + $data['text_comments'] = $this->language->get('text_comments'); |
|
| 65 | + $data['text_loading'] = $this->language->get('text_loading'); |
|
| 66 | 66 | |
| 67 | - $data['button_continue'] = $this->language->get('button_continue'); |
|
| 67 | + $data['button_continue'] = $this->language->get('button_continue'); |
|
| 68 | 68 | |
| 69 | - if (empty($this->session->data['shipping_methods'])) { |
|
| 70 | - $data['error_warning'] = sprintf($this->language->get('error_no_shipping'), $this->url->link('information/contact')); |
|
| 71 | - } else { |
|
| 72 | - $data['error_warning'] = ''; |
|
| 73 | - } |
|
| 69 | + if (empty($this->session->data['shipping_methods'])) { |
|
| 70 | + $data['error_warning'] = sprintf($this->language->get('error_no_shipping'), $this->url->link('information/contact')); |
|
| 71 | + } else { |
|
| 72 | + $data['error_warning'] = ''; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - if (isset($this->session->data['shipping_methods'])) { |
|
| 76 | - $data['shipping_methods'] = $this->session->data['shipping_methods']; |
|
| 77 | - } else { |
|
| 78 | - $data['shipping_methods'] = array(); |
|
| 79 | - } |
|
| 75 | + if (isset($this->session->data['shipping_methods'])) { |
|
| 76 | + $data['shipping_methods'] = $this->session->data['shipping_methods']; |
|
| 77 | + } else { |
|
| 78 | + $data['shipping_methods'] = array(); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - if (isset($this->session->data['shipping_method']['code'])) { |
|
| 82 | - $data['code'] = $this->session->data['shipping_method']['code']; |
|
| 83 | - } else { |
|
| 84 | - $data['code'] = ''; |
|
| 85 | - } |
|
| 81 | + if (isset($this->session->data['shipping_method']['code'])) { |
|
| 82 | + $data['code'] = $this->session->data['shipping_method']['code']; |
|
| 83 | + } else { |
|
| 84 | + $data['code'] = ''; |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - if (isset($this->session->data['comment'])) { |
|
| 88 | - $data['comment'] = $this->session->data['comment']; |
|
| 89 | - } else { |
|
| 90 | - $data['comment'] = ''; |
|
| 91 | - } |
|
| 87 | + if (isset($this->session->data['comment'])) { |
|
| 88 | + $data['comment'] = $this->session->data['comment']; |
|
| 89 | + } else { |
|
| 90 | + $data['comment'] = ''; |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - $this->response->setOutput($this->load->view('checkout/shipping_method', $data)); |
|
| 94 | - } |
|
| 93 | + $this->response->setOutput($this->load->view('checkout/shipping_method', $data)); |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - public function save() { |
|
| 97 | - $this->load->language('checkout/checkout'); |
|
| 96 | + public function save() { |
|
| 97 | + $this->load->language('checkout/checkout'); |
|
| 98 | 98 | |
| 99 | - $json = array(); |
|
| 99 | + $json = array(); |
|
| 100 | 100 | |
| 101 | - // Validate if shipping is required. If not the customer should not have reached this page. |
|
| 102 | - if (!$this->cart->hasShipping()) { |
|
| 103 | - $json['redirect'] = $this->url->link('checkout/checkout', '', true); |
|
| 104 | - } |
|
| 101 | + // Validate if shipping is required. If not the customer should not have reached this page. |
|
| 102 | + if (!$this->cart->hasShipping()) { |
|
| 103 | + $json['redirect'] = $this->url->link('checkout/checkout', '', true); |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - // Validate if shipping address has been set. |
|
| 107 | - if (!isset($this->session->data['shipping_address'])) { |
|
| 108 | - $json['redirect'] = $this->url->link('checkout/checkout', '', true); |
|
| 109 | - } |
|
| 106 | + // Validate if shipping address has been set. |
|
| 107 | + if (!isset($this->session->data['shipping_address'])) { |
|
| 108 | + $json['redirect'] = $this->url->link('checkout/checkout', '', true); |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - // Validate cart has products and has stock. |
|
| 112 | - if (!$this->cart->hasProducts()) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { |
|
| 113 | - $json['redirect'] = $this->url->link('checkout/cart'); |
|
| 114 | - } |
|
| 111 | + // Validate cart has products and has stock. |
|
| 112 | + if (!$this->cart->hasProducts()) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { |
|
| 113 | + $json['redirect'] = $this->url->link('checkout/cart'); |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - // Validate minimum quantity requirements. |
|
| 117 | - $products = $this->cart->getProducts(); |
|
| 116 | + // Validate minimum quantity requirements. |
|
| 117 | + $products = $this->cart->getProducts(); |
|
| 118 | 118 | |
| 119 | - foreach ($products as $product) { |
|
| 120 | - $product_total = 0; |
|
| 119 | + foreach ($products as $product) { |
|
| 120 | + $product_total = 0; |
|
| 121 | 121 | |
| 122 | - foreach ($products as $product_2) { |
|
| 123 | - if ($product_2['product_id'] == $product['product_id']) { |
|
| 124 | - $product_total += $product_2['quantity']; |
|
| 125 | - } |
|
| 126 | - } |
|
| 122 | + foreach ($products as $product_2) { |
|
| 123 | + if ($product_2['product_id'] == $product['product_id']) { |
|
| 124 | + $product_total += $product_2['quantity']; |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | 127 | |
| 128 | - if ($product['minimum'] > $product_total) { |
|
| 129 | - $json['redirect'] = $this->url->link('checkout/cart'); |
|
| 128 | + if ($product['minimum'] > $product_total) { |
|
| 129 | + $json['redirect'] = $this->url->link('checkout/cart'); |
|
| 130 | 130 | |
| 131 | - break; |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - if (!isset($this->request->post['shipping_method'])) { |
|
| 136 | - $json['error']['warning'] = $this->language->get('error_shipping'); |
|
| 137 | - } else { |
|
| 138 | - $shipping = explode('.', $this->request->post['shipping_method']); |
|
| 139 | - |
|
| 140 | - if (!isset($shipping[0]) || !isset($shipping[1]) || !isset($this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]])) { |
|
| 141 | - $json['error']['warning'] = $this->language->get('error_shipping'); |
|
| 142 | - } |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - if (!$json) { |
|
| 146 | - $this->session->data['shipping_method'] = $this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]]; |
|
| 131 | + break; |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + if (!isset($this->request->post['shipping_method'])) { |
|
| 136 | + $json['error']['warning'] = $this->language->get('error_shipping'); |
|
| 137 | + } else { |
|
| 138 | + $shipping = explode('.', $this->request->post['shipping_method']); |
|
| 139 | + |
|
| 140 | + if (!isset($shipping[0]) || !isset($shipping[1]) || !isset($this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]])) { |
|
| 141 | + $json['error']['warning'] = $this->language->get('error_shipping'); |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + if (!$json) { |
|
| 146 | + $this->session->data['shipping_method'] = $this->session->data['shipping_methods'][$shipping[0]]['quote'][$shipping[1]]; |
|
| 147 | 147 | |
| 148 | - $this->session->data['comment'] = strip_tags($this->request->post['comment']); |
|
| 149 | - } |
|
| 148 | + $this->session->data['comment'] = strip_tags($this->request->post['comment']); |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - $this->response->addHeader('Content-Type: application/json'); |
|
| 152 | - $this->response->setOutput(json_encode($json)); |
|
| 153 | - } |
|
| 151 | + $this->response->addHeader('Content-Type: application/json'); |
|
| 152 | + $this->response->setOutput(json_encode($json)); |
|
| 153 | + } |
|
| 154 | 154 | } |
| 155 | 155 | \ No newline at end of file |
@@ -109,9 +109,11 @@ |
||
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | // Validate cart has products and has stock. |
| 112 | - if (!$this->cart->hasProducts()) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { |
|
| 112 | + if (!$this->cart->hasProducts()) { |
|
| 113 | + || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { |
|
| 113 | 114 | $json['redirect'] = $this->url->link('checkout/cart'); |
| 114 | 115 | } |
| 116 | + } |
|
| 115 | 117 | |
| 116 | 118 | // Validate minimum quantity requirements. |
| 117 | 119 | $products = $this->cart->getProducts(); |
@@ -21,141 +21,141 @@ |
||
| 21 | 21 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
| 22 | 22 | |
| 23 | 23 | class ControllerCheckoutCheckout extends \Sunrise\Engine\Core\Controller { |
| 24 | - public function index() { |
|
| 25 | - // Validate cart has products and has stock. |
|
| 26 | - if (!$this->cart->hasProducts()) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { |
|
| 27 | - $this->response->redirect($this->url->link('checkout/cart')); |
|
| 28 | - } |
|
| 24 | + public function index() { |
|
| 25 | + // Validate cart has products and has stock. |
|
| 26 | + if (!$this->cart->hasProducts()) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { |
|
| 27 | + $this->response->redirect($this->url->link('checkout/cart')); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - // Validate minimum quantity requirements. |
|
| 31 | - $products = $this->cart->getProducts(); |
|
| 30 | + // Validate minimum quantity requirements. |
|
| 31 | + $products = $this->cart->getProducts(); |
|
| 32 | 32 | |
| 33 | - foreach ($products as $product) { |
|
| 34 | - $product_total = 0; |
|
| 33 | + foreach ($products as $product) { |
|
| 34 | + $product_total = 0; |
|
| 35 | 35 | |
| 36 | - foreach ($products as $product_2) { |
|
| 37 | - if ($product_2['product_id'] == $product['product_id']) { |
|
| 38 | - $product_total += $product_2['quantity']; |
|
| 39 | - } |
|
| 40 | - } |
|
| 36 | + foreach ($products as $product_2) { |
|
| 37 | + if ($product_2['product_id'] == $product['product_id']) { |
|
| 38 | + $product_total += $product_2['quantity']; |
|
| 39 | + } |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - if ($product['minimum'] > $product_total) { |
|
| 43 | - $this->response->redirect($this->url->link('checkout/cart')); |
|
| 44 | - } |
|
| 45 | - } |
|
| 42 | + if ($product['minimum'] > $product_total) { |
|
| 43 | + $this->response->redirect($this->url->link('checkout/cart')); |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - $this->load->language('checkout/checkout'); |
|
| 47 | + $this->load->language('checkout/checkout'); |
|
| 48 | 48 | |
| 49 | - $this->document->setTitle($this->language->get('heading_title')); |
|
| 49 | + $this->document->setTitle($this->language->get('heading_title')); |
|
| 50 | 50 | |
| 51 | - $data['breadcrumbs'] = array(); |
|
| 51 | + $data['breadcrumbs'] = array(); |
|
| 52 | 52 | |
| 53 | - $data['breadcrumbs'][] = array( |
|
| 54 | - 'text' => $this->language->get('text_home'), |
|
| 55 | - 'href' => $this->url->link('common/home') |
|
| 56 | - ); |
|
| 53 | + $data['breadcrumbs'][] = array( |
|
| 54 | + 'text' => $this->language->get('text_home'), |
|
| 55 | + 'href' => $this->url->link('common/home') |
|
| 56 | + ); |
|
| 57 | 57 | |
| 58 | - $data['breadcrumbs'][] = array( |
|
| 59 | - 'text' => $this->language->get('text_cart'), |
|
| 60 | - 'href' => $this->url->link('checkout/cart') |
|
| 61 | - ); |
|
| 58 | + $data['breadcrumbs'][] = array( |
|
| 59 | + 'text' => $this->language->get('text_cart'), |
|
| 60 | + 'href' => $this->url->link('checkout/cart') |
|
| 61 | + ); |
|
| 62 | 62 | |
| 63 | - $data['breadcrumbs'][] = array( |
|
| 64 | - 'text' => $this->language->get('heading_title'), |
|
| 65 | - 'href' => $this->url->link('checkout/checkout', '', true) |
|
| 66 | - ); |
|
| 63 | + $data['breadcrumbs'][] = array( |
|
| 64 | + 'text' => $this->language->get('heading_title'), |
|
| 65 | + 'href' => $this->url->link('checkout/checkout', '', true) |
|
| 66 | + ); |
|
| 67 | 67 | |
| 68 | - $data['heading_title'] = $this->language->get('heading_title'); |
|
| 68 | + $data['heading_title'] = $this->language->get('heading_title'); |
|
| 69 | 69 | |
| 70 | - $data['text_checkout_option'] = sprintf($this->language->get('text_checkout_option'), 1); |
|
| 71 | - $data['text_checkout_account'] = sprintf($this->language->get('text_checkout_account'), 2); |
|
| 72 | - $data['text_checkout_payment_address'] = sprintf($this->language->get('text_checkout_payment_address'), 2); |
|
| 73 | - $data['text_checkout_shipping_address'] = sprintf($this->language->get('text_checkout_shipping_address'), 3); |
|
| 74 | - $data['text_checkout_shipping_method'] = sprintf($this->language->get('text_checkout_shipping_method'), 4); |
|
| 70 | + $data['text_checkout_option'] = sprintf($this->language->get('text_checkout_option'), 1); |
|
| 71 | + $data['text_checkout_account'] = sprintf($this->language->get('text_checkout_account'), 2); |
|
| 72 | + $data['text_checkout_payment_address'] = sprintf($this->language->get('text_checkout_payment_address'), 2); |
|
| 73 | + $data['text_checkout_shipping_address'] = sprintf($this->language->get('text_checkout_shipping_address'), 3); |
|
| 74 | + $data['text_checkout_shipping_method'] = sprintf($this->language->get('text_checkout_shipping_method'), 4); |
|
| 75 | 75 | |
| 76 | - if ($this->cart->hasShipping()) { |
|
| 77 | - $data['text_checkout_payment_method'] = sprintf($this->language->get('text_checkout_payment_method'), 5); |
|
| 78 | - $data['text_checkout_confirm'] = sprintf($this->language->get('text_checkout_confirm'), 6); |
|
| 79 | - } else { |
|
| 80 | - $data['text_checkout_payment_method'] = sprintf($this->language->get('text_checkout_payment_method'), 3); |
|
| 81 | - $data['text_checkout_confirm'] = sprintf($this->language->get('text_checkout_confirm'), 4); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - if (isset($this->session->data['error'])) { |
|
| 85 | - $data['error_warning'] = $this->session->data['error']; |
|
| 86 | - unset($this->session->data['error']); |
|
| 87 | - } else { |
|
| 88 | - $data['error_warning'] = ''; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - $data['logged'] = $this->customer->isLogged(); |
|
| 92 | - |
|
| 93 | - if (isset($this->session->data['account'])) { |
|
| 94 | - $data['account'] = $this->session->data['account']; |
|
| 95 | - } else { |
|
| 96 | - $data['account'] = ''; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - $data['shipping_required'] = $this->cart->hasShipping(); |
|
| 100 | - |
|
| 101 | - $data['column'] = $this->load->controller('common/column'); |
|
| 76 | + if ($this->cart->hasShipping()) { |
|
| 77 | + $data['text_checkout_payment_method'] = sprintf($this->language->get('text_checkout_payment_method'), 5); |
|
| 78 | + $data['text_checkout_confirm'] = sprintf($this->language->get('text_checkout_confirm'), 6); |
|
| 79 | + } else { |
|
| 80 | + $data['text_checkout_payment_method'] = sprintf($this->language->get('text_checkout_payment_method'), 3); |
|
| 81 | + $data['text_checkout_confirm'] = sprintf($this->language->get('text_checkout_confirm'), 4); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + if (isset($this->session->data['error'])) { |
|
| 85 | + $data['error_warning'] = $this->session->data['error']; |
|
| 86 | + unset($this->session->data['error']); |
|
| 87 | + } else { |
|
| 88 | + $data['error_warning'] = ''; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + $data['logged'] = $this->customer->isLogged(); |
|
| 92 | + |
|
| 93 | + if (isset($this->session->data['account'])) { |
|
| 94 | + $data['account'] = $this->session->data['account']; |
|
| 95 | + } else { |
|
| 96 | + $data['account'] = ''; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + $data['shipping_required'] = $this->cart->hasShipping(); |
|
| 100 | + |
|
| 101 | + $data['column'] = $this->load->controller('common/column'); |
|
| 102 | 102 | |
| 103 | - $data['content_top'] = $this->load->controller('common/content_top'); |
|
| 104 | - $data['content_bottom'] = $this->load->controller('common/content_bottom'); |
|
| 105 | - $data['footer'] = $this->load->controller('common/footer'); |
|
| 106 | - $data['header'] = $this->load->controller('common/header'); |
|
| 107 | - |
|
| 108 | - $this->response->setOutput($this->load->view('checkout/checkout', $data)); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - public function country() { |
|
| 112 | - $json = array(); |
|
| 113 | - |
|
| 114 | - $this->load->model('localisation/country'); |
|
| 115 | - |
|
| 116 | - $country_info = $this->model_localisation_country->getCountry($this->request->get['country_id']); |
|
| 117 | - |
|
| 118 | - if ($country_info) { |
|
| 119 | - $this->load->model('localisation/zone'); |
|
| 120 | - |
|
| 121 | - $json = array( |
|
| 122 | - 'country_id' => $country_info['country_id'], |
|
| 123 | - 'name' => $country_info['name'], |
|
| 124 | - 'iso_code_2' => $country_info['iso_code_2'], |
|
| 125 | - 'iso_code_3' => $country_info['iso_code_3'], |
|
| 126 | - 'address_format' => $country_info['address_format'], |
|
| 127 | - 'postcode_required' => $country_info['postcode_required'], |
|
| 128 | - 'zone' => $this->model_localisation_zone->getZonesByCountryId($this->request->get['country_id']), |
|
| 129 | - 'status' => $country_info['status'] |
|
| 130 | - ); |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - $this->response->addHeader('Content-Type: application/json'); |
|
| 134 | - $this->response->setOutput(json_encode($json)); |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - public function customfield() { |
|
| 138 | - $json = array(); |
|
| 139 | - |
|
| 140 | - $this->load->model('account/custom_field'); |
|
| 141 | - |
|
| 142 | - // Customer Group |
|
| 143 | - if (isset($this->request->get['customer_group_id']) && is_array($this->config->get('config_customer_group_display')) && in_array($this->request->get['customer_group_id'], $this->config->get('config_customer_group_display'))) { |
|
| 144 | - $customer_group_id = $this->request->get['customer_group_id']; |
|
| 145 | - } else { |
|
| 146 | - $customer_group_id = $this->config->get('config_customer_group_id'); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - $custom_fields = $this->model_account_custom_field->getCustomFields($customer_group_id); |
|
| 150 | - |
|
| 151 | - foreach ($custom_fields as $custom_field) { |
|
| 152 | - $json[] = array( |
|
| 153 | - 'custom_field_id' => $custom_field['custom_field_id'], |
|
| 154 | - 'required' => $custom_field['required'] |
|
| 155 | - ); |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - $this->response->addHeader('Content-Type: application/json'); |
|
| 159 | - $this->response->setOutput(json_encode($json)); |
|
| 160 | - } |
|
| 103 | + $data['content_top'] = $this->load->controller('common/content_top'); |
|
| 104 | + $data['content_bottom'] = $this->load->controller('common/content_bottom'); |
|
| 105 | + $data['footer'] = $this->load->controller('common/footer'); |
|
| 106 | + $data['header'] = $this->load->controller('common/header'); |
|
| 107 | + |
|
| 108 | + $this->response->setOutput($this->load->view('checkout/checkout', $data)); |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + public function country() { |
|
| 112 | + $json = array(); |
|
| 113 | + |
|
| 114 | + $this->load->model('localisation/country'); |
|
| 115 | + |
|
| 116 | + $country_info = $this->model_localisation_country->getCountry($this->request->get['country_id']); |
|
| 117 | + |
|
| 118 | + if ($country_info) { |
|
| 119 | + $this->load->model('localisation/zone'); |
|
| 120 | + |
|
| 121 | + $json = array( |
|
| 122 | + 'country_id' => $country_info['country_id'], |
|
| 123 | + 'name' => $country_info['name'], |
|
| 124 | + 'iso_code_2' => $country_info['iso_code_2'], |
|
| 125 | + 'iso_code_3' => $country_info['iso_code_3'], |
|
| 126 | + 'address_format' => $country_info['address_format'], |
|
| 127 | + 'postcode_required' => $country_info['postcode_required'], |
|
| 128 | + 'zone' => $this->model_localisation_zone->getZonesByCountryId($this->request->get['country_id']), |
|
| 129 | + 'status' => $country_info['status'] |
|
| 130 | + ); |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + $this->response->addHeader('Content-Type: application/json'); |
|
| 134 | + $this->response->setOutput(json_encode($json)); |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + public function customfield() { |
|
| 138 | + $json = array(); |
|
| 139 | + |
|
| 140 | + $this->load->model('account/custom_field'); |
|
| 141 | + |
|
| 142 | + // Customer Group |
|
| 143 | + if (isset($this->request->get['customer_group_id']) && is_array($this->config->get('config_customer_group_display')) && in_array($this->request->get['customer_group_id'], $this->config->get('config_customer_group_display'))) { |
|
| 144 | + $customer_group_id = $this->request->get['customer_group_id']; |
|
| 145 | + } else { |
|
| 146 | + $customer_group_id = $this->config->get('config_customer_group_id'); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + $custom_fields = $this->model_account_custom_field->getCustomFields($customer_group_id); |
|
| 150 | + |
|
| 151 | + foreach ($custom_fields as $custom_field) { |
|
| 152 | + $json[] = array( |
|
| 153 | + 'custom_field_id' => $custom_field['custom_field_id'], |
|
| 154 | + 'required' => $custom_field['required'] |
|
| 155 | + ); |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + $this->response->addHeader('Content-Type: application/json'); |
|
| 159 | + $this->response->setOutput(json_encode($json)); |
|
| 160 | + } |
|
| 161 | 161 | } |
@@ -23,9 +23,11 @@ |
||
| 23 | 23 | class ControllerCheckoutCheckout extends \Sunrise\Engine\Core\Controller { |
| 24 | 24 | public function index() { |
| 25 | 25 | // Validate cart has products and has stock. |
| 26 | - if (!$this->cart->hasProducts()) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { |
|
| 26 | + if (!$this->cart->hasProducts()) { |
|
| 27 | + || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { |
|
| 27 | 28 | $this->response->redirect($this->url->link('checkout/cart')); |
| 28 | 29 | } |
| 30 | + } |
|
| 29 | 31 | |
| 30 | 32 | // Validate minimum quantity requirements. |
| 31 | 33 | $products = $this->cart->getProducts(); |
@@ -21,257 +21,257 @@ |
||
| 21 | 21 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
| 22 | 22 | |
| 23 | 23 | class ControllerCheckoutRegister extends \Sunrise\Engine\Core\Controller { |
| 24 | - public function index() { |
|
| 25 | - $this->load->language('checkout/checkout'); |
|
| 26 | - |
|
| 27 | - $data['text_checkout_payment_address'] = $this->language->get('text_checkout_payment_address'); |
|
| 28 | - $data['text_your_details'] = $this->language->get('text_your_details'); |
|
| 29 | - $data['text_your_address'] = $this->language->get('text_your_address'); |
|
| 30 | - $data['text_your_password'] = $this->language->get('text_your_password'); |
|
| 31 | - $data['text_select'] = $this->language->get('text_select'); |
|
| 32 | - $data['text_none'] = $this->language->get('text_none'); |
|
| 33 | - $data['text_loading'] = $this->language->get('text_loading'); |
|
| 34 | - |
|
| 35 | - $data['entry_customer_group'] = $this->language->get('entry_customer_group'); |
|
| 36 | - $data['entry_firstname'] = $this->language->get('entry_firstname'); |
|
| 37 | - $data['entry_lastname'] = $this->language->get('entry_lastname'); |
|
| 38 | - $data['entry_email'] = $this->language->get('entry_email'); |
|
| 39 | - $data['entry_telephone'] = $this->language->get('entry_telephone'); |
|
| 40 | - $data['entry_fax'] = $this->language->get('entry_fax'); |
|
| 41 | - $data['entry_company'] = $this->language->get('entry_company'); |
|
| 42 | - $data['entry_address_1'] = $this->language->get('entry_address_1'); |
|
| 43 | - $data['entry_address_2'] = $this->language->get('entry_address_2'); |
|
| 44 | - $data['entry_postcode'] = $this->language->get('entry_postcode'); |
|
| 45 | - $data['entry_city'] = $this->language->get('entry_city'); |
|
| 46 | - $data['entry_country'] = $this->language->get('entry_country'); |
|
| 47 | - $data['entry_zone'] = $this->language->get('entry_zone'); |
|
| 48 | - $data['entry_newsletter'] = sprintf($this->language->get('entry_newsletter'), $this->config->get('config_name')); |
|
| 49 | - $data['entry_password'] = $this->language->get('entry_password'); |
|
| 50 | - $data['entry_confirm'] = $this->language->get('entry_confirm'); |
|
| 51 | - $data['entry_shipping'] = $this->language->get('entry_shipping'); |
|
| 52 | - |
|
| 53 | - $data['button_continue'] = $this->language->get('button_continue'); |
|
| 54 | - $data['button_upload'] = $this->language->get('button_upload'); |
|
| 55 | - |
|
| 56 | - $data['customer_groups'] = array(); |
|
| 57 | - |
|
| 58 | - if (is_array($this->config->get('config_customer_group_display'))) { |
|
| 59 | - $this->load->model('account/customer_group'); |
|
| 60 | - |
|
| 61 | - $customer_groups = $this->model_account_customer_group->getCustomerGroups(); |
|
| 62 | - |
|
| 63 | - foreach ($customer_groups as $customer_group) { |
|
| 64 | - if (in_array($customer_group['customer_group_id'], $this->config->get('config_customer_group_display'))) { |
|
| 65 | - $data['customer_groups'][] = $customer_group; |
|
| 66 | - } |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - $data['customer_group_id'] = $this->config->get('config_customer_group_id'); |
|
| 71 | - |
|
| 72 | - if (isset($this->session->data['shipping_address']['postcode'])) { |
|
| 73 | - $data['postcode'] = $this->session->data['shipping_address']['postcode']; |
|
| 74 | - } else { |
|
| 75 | - $data['postcode'] = ''; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - if (isset($this->session->data['shipping_address']['country_id'])) { |
|
| 79 | - $data['country_id'] = $this->session->data['shipping_address']['country_id']; |
|
| 80 | - } else { |
|
| 81 | - $data['country_id'] = $this->config->get('config_country_id'); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - if (isset($this->session->data['shipping_address']['zone_id'])) { |
|
| 85 | - $data['zone_id'] = $this->session->data['shipping_address']['zone_id']; |
|
| 86 | - } else { |
|
| 87 | - $data['zone_id'] = ''; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - $this->load->model('localisation/country'); |
|
| 91 | - |
|
| 92 | - $data['countries'] = $this->model_localisation_country->getCountries(); |
|
| 93 | - |
|
| 94 | - // Custom Fields |
|
| 95 | - $this->load->model('account/custom_field'); |
|
| 96 | - |
|
| 97 | - $data['custom_fields'] = $this->model_account_custom_field->getCustomFields(); |
|
| 24 | + public function index() { |
|
| 25 | + $this->load->language('checkout/checkout'); |
|
| 26 | + |
|
| 27 | + $data['text_checkout_payment_address'] = $this->language->get('text_checkout_payment_address'); |
|
| 28 | + $data['text_your_details'] = $this->language->get('text_your_details'); |
|
| 29 | + $data['text_your_address'] = $this->language->get('text_your_address'); |
|
| 30 | + $data['text_your_password'] = $this->language->get('text_your_password'); |
|
| 31 | + $data['text_select'] = $this->language->get('text_select'); |
|
| 32 | + $data['text_none'] = $this->language->get('text_none'); |
|
| 33 | + $data['text_loading'] = $this->language->get('text_loading'); |
|
| 34 | + |
|
| 35 | + $data['entry_customer_group'] = $this->language->get('entry_customer_group'); |
|
| 36 | + $data['entry_firstname'] = $this->language->get('entry_firstname'); |
|
| 37 | + $data['entry_lastname'] = $this->language->get('entry_lastname'); |
|
| 38 | + $data['entry_email'] = $this->language->get('entry_email'); |
|
| 39 | + $data['entry_telephone'] = $this->language->get('entry_telephone'); |
|
| 40 | + $data['entry_fax'] = $this->language->get('entry_fax'); |
|
| 41 | + $data['entry_company'] = $this->language->get('entry_company'); |
|
| 42 | + $data['entry_address_1'] = $this->language->get('entry_address_1'); |
|
| 43 | + $data['entry_address_2'] = $this->language->get('entry_address_2'); |
|
| 44 | + $data['entry_postcode'] = $this->language->get('entry_postcode'); |
|
| 45 | + $data['entry_city'] = $this->language->get('entry_city'); |
|
| 46 | + $data['entry_country'] = $this->language->get('entry_country'); |
|
| 47 | + $data['entry_zone'] = $this->language->get('entry_zone'); |
|
| 48 | + $data['entry_newsletter'] = sprintf($this->language->get('entry_newsletter'), $this->config->get('config_name')); |
|
| 49 | + $data['entry_password'] = $this->language->get('entry_password'); |
|
| 50 | + $data['entry_confirm'] = $this->language->get('entry_confirm'); |
|
| 51 | + $data['entry_shipping'] = $this->language->get('entry_shipping'); |
|
| 52 | + |
|
| 53 | + $data['button_continue'] = $this->language->get('button_continue'); |
|
| 54 | + $data['button_upload'] = $this->language->get('button_upload'); |
|
| 55 | + |
|
| 56 | + $data['customer_groups'] = array(); |
|
| 57 | + |
|
| 58 | + if (is_array($this->config->get('config_customer_group_display'))) { |
|
| 59 | + $this->load->model('account/customer_group'); |
|
| 60 | + |
|
| 61 | + $customer_groups = $this->model_account_customer_group->getCustomerGroups(); |
|
| 62 | + |
|
| 63 | + foreach ($customer_groups as $customer_group) { |
|
| 64 | + if (in_array($customer_group['customer_group_id'], $this->config->get('config_customer_group_display'))) { |
|
| 65 | + $data['customer_groups'][] = $customer_group; |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + $data['customer_group_id'] = $this->config->get('config_customer_group_id'); |
|
| 71 | + |
|
| 72 | + if (isset($this->session->data['shipping_address']['postcode'])) { |
|
| 73 | + $data['postcode'] = $this->session->data['shipping_address']['postcode']; |
|
| 74 | + } else { |
|
| 75 | + $data['postcode'] = ''; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + if (isset($this->session->data['shipping_address']['country_id'])) { |
|
| 79 | + $data['country_id'] = $this->session->data['shipping_address']['country_id']; |
|
| 80 | + } else { |
|
| 81 | + $data['country_id'] = $this->config->get('config_country_id'); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + if (isset($this->session->data['shipping_address']['zone_id'])) { |
|
| 85 | + $data['zone_id'] = $this->session->data['shipping_address']['zone_id']; |
|
| 86 | + } else { |
|
| 87 | + $data['zone_id'] = ''; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + $this->load->model('localisation/country'); |
|
| 91 | + |
|
| 92 | + $data['countries'] = $this->model_localisation_country->getCountries(); |
|
| 93 | + |
|
| 94 | + // Custom Fields |
|
| 95 | + $this->load->model('account/custom_field'); |
|
| 96 | + |
|
| 97 | + $data['custom_fields'] = $this->model_account_custom_field->getCustomFields(); |
|
| 98 | 98 | |
| 99 | - if ($this->config->get('config_account_id')) { |
|
| 100 | - $this->load->model('catalog/information'); |
|
| 101 | - |
|
| 102 | - $information_info = $this->model_catalog_information->getInformation($this->config->get('config_account_id')); |
|
| 103 | - |
|
| 104 | - if ($information_info) { |
|
| 105 | - $data['text_agree'] = sprintf($this->language->get('text_agree'), $this->url->link('information/information/agree', 'information_id=' . $this->config->get('config_account_id'), true), $information_info['title'], $information_info['title']); |
|
| 106 | - } else { |
|
| 107 | - $data['text_agree'] = ''; |
|
| 108 | - } |
|
| 109 | - } else { |
|
| 110 | - $data['text_agree'] = ''; |
|
| 111 | - } |
|
| 99 | + if ($this->config->get('config_account_id')) { |
|
| 100 | + $this->load->model('catalog/information'); |
|
| 101 | + |
|
| 102 | + $information_info = $this->model_catalog_information->getInformation($this->config->get('config_account_id')); |
|
| 103 | + |
|
| 104 | + if ($information_info) { |
|
| 105 | + $data['text_agree'] = sprintf($this->language->get('text_agree'), $this->url->link('information/information/agree', 'information_id=' . $this->config->get('config_account_id'), true), $information_info['title'], $information_info['title']); |
|
| 106 | + } else { |
|
| 107 | + $data['text_agree'] = ''; |
|
| 108 | + } |
|
| 109 | + } else { |
|
| 110 | + $data['text_agree'] = ''; |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - $data['shipping_required'] = $this->cart->hasShipping(); |
|
| 113 | + $data['shipping_required'] = $this->cart->hasShipping(); |
|
| 114 | 114 | |
| 115 | - $this->response->setOutput($this->load->view('checkout/register', $data)); |
|
| 116 | - } |
|
| 115 | + $this->response->setOutput($this->load->view('checkout/register', $data)); |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - public function save() { |
|
| 119 | - $this->load->language('checkout/checkout'); |
|
| 120 | - |
|
| 121 | - $json = array(); |
|
| 122 | - |
|
| 123 | - // Validate if customer is already logged out. |
|
| 124 | - if ($this->customer->isLogged()) { |
|
| 125 | - $json['redirect'] = $this->url->link('checkout/checkout', '', true); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - // Validate cart has products and has stock. |
|
| 129 | - if ((!$this->cart->hasProducts()) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { |
|
| 130 | - $json['redirect'] = $this->url->link('checkout/cart'); |
|
| 131 | - } |
|
| 118 | + public function save() { |
|
| 119 | + $this->load->language('checkout/checkout'); |
|
| 120 | + |
|
| 121 | + $json = array(); |
|
| 122 | + |
|
| 123 | + // Validate if customer is already logged out. |
|
| 124 | + if ($this->customer->isLogged()) { |
|
| 125 | + $json['redirect'] = $this->url->link('checkout/checkout', '', true); |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + // Validate cart has products and has stock. |
|
| 129 | + if ((!$this->cart->hasProducts()) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { |
|
| 130 | + $json['redirect'] = $this->url->link('checkout/cart'); |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - // Validate minimum quantity requirements. |
|
| 134 | - $products = $this->cart->getProducts(); |
|
| 135 | - |
|
| 136 | - foreach ($products as $product) { |
|
| 137 | - $product_total = 0; |
|
| 133 | + // Validate minimum quantity requirements. |
|
| 134 | + $products = $this->cart->getProducts(); |
|
| 135 | + |
|
| 136 | + foreach ($products as $product) { |
|
| 137 | + $product_total = 0; |
|
| 138 | 138 | |
| 139 | - foreach ($products as $product_2) { |
|
| 140 | - if ($product_2['product_id'] == $product['product_id']) { |
|
| 141 | - $product_total += $product_2['quantity']; |
|
| 142 | - } |
|
| 143 | - } |
|
| 139 | + foreach ($products as $product_2) { |
|
| 140 | + if ($product_2['product_id'] == $product['product_id']) { |
|
| 141 | + $product_total += $product_2['quantity']; |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - if ($product['minimum'] > $product_total) { |
|
| 146 | - $json['redirect'] = $this->url->link('checkout/cart'); |
|
| 145 | + if ($product['minimum'] > $product_total) { |
|
| 146 | + $json['redirect'] = $this->url->link('checkout/cart'); |
|
| 147 | 147 | |
| 148 | - break; |
|
| 149 | - } |
|
| 150 | - } |
|
| 148 | + break; |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - if (!$json) { |
|
| 153 | - $this->load->model('account/customer'); |
|
| 152 | + if (!$json) { |
|
| 153 | + $this->load->model('account/customer'); |
|
| 154 | 154 | |
| 155 | - if ((\voku\helper\UTF8::strlen(trim($this->request->post['firstname'])) < 1) || (\voku\helper\UTF8::strlen(trim($this->request->post['firstname'])) > 32)) { |
|
| 156 | - $json['error']['firstname'] = $this->language->get('error_firstname'); |
|
| 157 | - } |
|
| 155 | + if ((\voku\helper\UTF8::strlen(trim($this->request->post['firstname'])) < 1) || (\voku\helper\UTF8::strlen(trim($this->request->post['firstname'])) > 32)) { |
|
| 156 | + $json['error']['firstname'] = $this->language->get('error_firstname'); |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - if ((\voku\helper\UTF8::strlen(trim($this->request->post['lastname'])) < 1) || (\voku\helper\UTF8::strlen(trim($this->request->post['lastname'])) > 32)) { |
|
| 160 | - $json['error']['lastname'] = $this->language->get('error_lastname'); |
|
| 161 | - } |
|
| 159 | + if ((\voku\helper\UTF8::strlen(trim($this->request->post['lastname'])) < 1) || (\voku\helper\UTF8::strlen(trim($this->request->post['lastname'])) > 32)) { |
|
| 160 | + $json['error']['lastname'] = $this->language->get('error_lastname'); |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | - if ((\voku\helper\UTF8::strlen($this->request->post['email']) > 96) || !filter_var($this->request->post['email'], FILTER_VALIDATE_EMAIL)) { |
|
| 164 | - $json['error']['email'] = $this->language->get('error_email'); |
|
| 165 | - } |
|
| 163 | + if ((\voku\helper\UTF8::strlen($this->request->post['email']) > 96) || !filter_var($this->request->post['email'], FILTER_VALIDATE_EMAIL)) { |
|
| 164 | + $json['error']['email'] = $this->language->get('error_email'); |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - if ($this->model_account_customer->getTotalCustomersByEmail($this->request->post['email'])) { |
|
| 168 | - $json['error']['warning'] = $this->language->get('error_exists'); |
|
| 169 | - } |
|
| 167 | + if ($this->model_account_customer->getTotalCustomersByEmail($this->request->post['email'])) { |
|
| 168 | + $json['error']['warning'] = $this->language->get('error_exists'); |
|
| 169 | + } |
|
| 170 | 170 | |
| 171 | - if ((\voku\helper\UTF8::strlen($this->request->post['telephone']) < 3) || (\voku\helper\UTF8::strlen($this->request->post['telephone']) > 32)) { |
|
| 172 | - $json['error']['telephone'] = $this->language->get('error_telephone'); |
|
| 173 | - } |
|
| 171 | + if ((\voku\helper\UTF8::strlen($this->request->post['telephone']) < 3) || (\voku\helper\UTF8::strlen($this->request->post['telephone']) > 32)) { |
|
| 172 | + $json['error']['telephone'] = $this->language->get('error_telephone'); |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - if ((\voku\helper\UTF8::strlen(trim($this->request->post['address_1'])) < 3) || (\voku\helper\UTF8::strlen(trim($this->request->post['address_1'])) > 128)) { |
|
| 176 | - $json['error']['address_1'] = $this->language->get('error_address_1'); |
|
| 177 | - } |
|
| 175 | + if ((\voku\helper\UTF8::strlen(trim($this->request->post['address_1'])) < 3) || (\voku\helper\UTF8::strlen(trim($this->request->post['address_1'])) > 128)) { |
|
| 176 | + $json['error']['address_1'] = $this->language->get('error_address_1'); |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - if ((\voku\helper\UTF8::strlen(trim($this->request->post['city'])) < 2) || (\voku\helper\UTF8::strlen(trim($this->request->post['city'])) > 128)) { |
|
| 180 | - $json['error']['city'] = $this->language->get('error_city'); |
|
| 181 | - } |
|
| 179 | + if ((\voku\helper\UTF8::strlen(trim($this->request->post['city'])) < 2) || (\voku\helper\UTF8::strlen(trim($this->request->post['city'])) > 128)) { |
|
| 180 | + $json['error']['city'] = $this->language->get('error_city'); |
|
| 181 | + } |
|
| 182 | 182 | |
| 183 | - $this->load->model('localisation/country'); |
|
| 183 | + $this->load->model('localisation/country'); |
|
| 184 | 184 | |
| 185 | - $country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']); |
|
| 185 | + $country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']); |
|
| 186 | 186 | |
| 187 | - if ($country_info && $country_info['postcode_required'] && (\voku\helper\UTF8::strlen(trim($this->request->post['postcode'])) < 2 || \voku\helper\UTF8::strlen(trim($this->request->post['postcode'])) > 10)) { |
|
| 188 | - $json['error']['postcode'] = $this->language->get('error_postcode'); |
|
| 189 | - } |
|
| 187 | + if ($country_info && $country_info['postcode_required'] && (\voku\helper\UTF8::strlen(trim($this->request->post['postcode'])) < 2 || \voku\helper\UTF8::strlen(trim($this->request->post['postcode'])) > 10)) { |
|
| 188 | + $json['error']['postcode'] = $this->language->get('error_postcode'); |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | - if ($this->request->post['country_id'] == '') { |
|
| 192 | - $json['error']['country'] = $this->language->get('error_country'); |
|
| 193 | - } |
|
| 191 | + if ($this->request->post['country_id'] == '') { |
|
| 192 | + $json['error']['country'] = $this->language->get('error_country'); |
|
| 193 | + } |
|
| 194 | 194 | |
| 195 | - if (!isset($this->request->post['zone_id']) || $this->request->post['zone_id'] == '' || !is_numeric($this->request->post['zone_id'])) { |
|
| 196 | - $json['error']['zone'] = $this->language->get('error_zone'); |
|
| 197 | - } |
|
| 195 | + if (!isset($this->request->post['zone_id']) || $this->request->post['zone_id'] == '' || !is_numeric($this->request->post['zone_id'])) { |
|
| 196 | + $json['error']['zone'] = $this->language->get('error_zone'); |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | - if ((\voku\helper\UTF8::strlen($this->request->post['password']) < 4) || (\voku\helper\UTF8::strlen($this->request->post['password']) > 20)) { |
|
| 200 | - $json['error']['password'] = $this->language->get('error_password'); |
|
| 201 | - } |
|
| 199 | + if ((\voku\helper\UTF8::strlen($this->request->post['password']) < 4) || (\voku\helper\UTF8::strlen($this->request->post['password']) > 20)) { |
|
| 200 | + $json['error']['password'] = $this->language->get('error_password'); |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | - if ($this->request->post['confirm'] != $this->request->post['password']) { |
|
| 204 | - $json['error']['confirm'] = $this->language->get('error_confirm'); |
|
| 205 | - } |
|
| 203 | + if ($this->request->post['confirm'] != $this->request->post['password']) { |
|
| 204 | + $json['error']['confirm'] = $this->language->get('error_confirm'); |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | - if ($this->config->get('config_account_id')) { |
|
| 208 | - $this->load->model('catalog/information'); |
|
| 207 | + if ($this->config->get('config_account_id')) { |
|
| 208 | + $this->load->model('catalog/information'); |
|
| 209 | 209 | |
| 210 | - $information_info = $this->model_catalog_information->getInformation($this->config->get('config_account_id')); |
|
| 210 | + $information_info = $this->model_catalog_information->getInformation($this->config->get('config_account_id')); |
|
| 211 | 211 | |
| 212 | - if ($information_info && !isset($this->request->post['agree'])) { |
|
| 213 | - $json['error']['warning'] = sprintf($this->language->get('error_agree'), $information_info['title']); |
|
| 214 | - } |
|
| 215 | - } |
|
| 212 | + if ($information_info && !isset($this->request->post['agree'])) { |
|
| 213 | + $json['error']['warning'] = sprintf($this->language->get('error_agree'), $information_info['title']); |
|
| 214 | + } |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | - // Customer Group |
|
| 218 | - if (isset($this->request->post['customer_group_id']) && is_array($this->config->get('config_customer_group_display')) && in_array($this->request->post['customer_group_id'], $this->config->get('config_customer_group_display'))) { |
|
| 219 | - $customer_group_id = $this->request->post['customer_group_id']; |
|
| 220 | - } else { |
|
| 221 | - $customer_group_id = $this->config->get('config_customer_group_id'); |
|
| 222 | - } |
|
| 217 | + // Customer Group |
|
| 218 | + if (isset($this->request->post['customer_group_id']) && is_array($this->config->get('config_customer_group_display')) && in_array($this->request->post['customer_group_id'], $this->config->get('config_customer_group_display'))) { |
|
| 219 | + $customer_group_id = $this->request->post['customer_group_id']; |
|
| 220 | + } else { |
|
| 221 | + $customer_group_id = $this->config->get('config_customer_group_id'); |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - // Custom field validation |
|
| 225 | - $this->load->model('account/custom_field'); |
|
| 224 | + // Custom field validation |
|
| 225 | + $this->load->model('account/custom_field'); |
|
| 226 | 226 | |
| 227 | - $custom_fields = $this->model_account_custom_field->getCustomFields($customer_group_id); |
|
| 227 | + $custom_fields = $this->model_account_custom_field->getCustomFields($customer_group_id); |
|
| 228 | 228 | |
| 229 | - foreach ($custom_fields as $custom_field) { |
|
| 230 | - if ($custom_field['required'] && empty($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']])) { |
|
| 231 | - $json['error']['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']); |
|
| 232 | - } elseif (($custom_field['type'] == 'text') && !empty($custom_field['validation']) && !filter_var($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $custom_field['validation'])))) { |
|
| 233 | - $json['error']['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']); |
|
| 234 | - } |
|
| 235 | - } |
|
| 229 | + foreach ($custom_fields as $custom_field) { |
|
| 230 | + if ($custom_field['required'] && empty($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']])) { |
|
| 231 | + $json['error']['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']); |
|
| 232 | + } elseif (($custom_field['type'] == 'text') && !empty($custom_field['validation']) && !filter_var($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $custom_field['validation'])))) { |
|
| 233 | + $json['error']['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']); |
|
| 234 | + } |
|
| 235 | + } |
|
| 236 | 236 | |
| 237 | - } |
|
| 237 | + } |
|
| 238 | 238 | |
| 239 | - if (!$json) { |
|
| 240 | - $customer_id = $this->model_account_customer->addCustomer($this->request->post); |
|
| 239 | + if (!$json) { |
|
| 240 | + $customer_id = $this->model_account_customer->addCustomer($this->request->post); |
|
| 241 | 241 | |
| 242 | - // Clear any previous login attempts for unregistered accounts. |
|
| 243 | - $this->model_account_customer->deleteLoginAttempts($this->request->post['email']); |
|
| 242 | + // Clear any previous login attempts for unregistered accounts. |
|
| 243 | + $this->model_account_customer->deleteLoginAttempts($this->request->post['email']); |
|
| 244 | 244 | |
| 245 | - $this->session->data['account'] = 'register'; |
|
| 245 | + $this->session->data['account'] = 'register'; |
|
| 246 | 246 | |
| 247 | - $this->load->model('account/customer_group'); |
|
| 247 | + $this->load->model('account/customer_group'); |
|
| 248 | 248 | |
| 249 | - $customer_group_info = $this->model_account_customer_group->getCustomerGroup($customer_group_id); |
|
| 249 | + $customer_group_info = $this->model_account_customer_group->getCustomerGroup($customer_group_id); |
|
| 250 | 250 | |
| 251 | - if ($customer_group_info && !$customer_group_info['approval']) { |
|
| 252 | - $this->customer->login($this->request->post['email'], $this->request->post['password']); |
|
| 251 | + if ($customer_group_info && !$customer_group_info['approval']) { |
|
| 252 | + $this->customer->login($this->request->post['email'], $this->request->post['password']); |
|
| 253 | 253 | |
| 254 | - // Default Payment Address |
|
| 255 | - $this->load->model('account/address'); |
|
| 254 | + // Default Payment Address |
|
| 255 | + $this->load->model('account/address'); |
|
| 256 | 256 | |
| 257 | - $this->session->data['payment_address'] = $this->model_account_address->getAddress($this->customer->getAddressId()); |
|
| 257 | + $this->session->data['payment_address'] = $this->model_account_address->getAddress($this->customer->getAddressId()); |
|
| 258 | 258 | |
| 259 | - if (!empty($this->request->post['shipping_address'])) { |
|
| 260 | - $this->session->data['shipping_address'] = $this->model_account_address->getAddress($this->customer->getAddressId()); |
|
| 261 | - } |
|
| 262 | - } else { |
|
| 263 | - $json['redirect'] = $this->url->link('account/success'); |
|
| 264 | - } |
|
| 259 | + if (!empty($this->request->post['shipping_address'])) { |
|
| 260 | + $this->session->data['shipping_address'] = $this->model_account_address->getAddress($this->customer->getAddressId()); |
|
| 261 | + } |
|
| 262 | + } else { |
|
| 263 | + $json['redirect'] = $this->url->link('account/success'); |
|
| 264 | + } |
|
| 265 | 265 | |
| 266 | - unset($this->session->data['guest']); |
|
| 267 | - unset($this->session->data['shipping_method']); |
|
| 268 | - unset($this->session->data['shipping_methods']); |
|
| 269 | - unset($this->session->data['payment_method']); |
|
| 270 | - unset($this->session->data['payment_methods']); |
|
| 266 | + unset($this->session->data['guest']); |
|
| 267 | + unset($this->session->data['shipping_method']); |
|
| 268 | + unset($this->session->data['shipping_methods']); |
|
| 269 | + unset($this->session->data['payment_method']); |
|
| 270 | + unset($this->session->data['payment_methods']); |
|
| 271 | 271 | |
| 272 | - } |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | - $this->response->addHeader('Content-Type: application/json'); |
|
| 275 | - $this->response->setOutput(json_encode($json)); |
|
| 276 | - } |
|
| 274 | + $this->response->addHeader('Content-Type: application/json'); |
|
| 275 | + $this->response->setOutput(json_encode($json)); |
|
| 276 | + } |
|
| 277 | 277 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | $this->load->language('checkout/success'); |
| 28 | 28 | |
| 29 | - if (isset($this->session->data['order_id']) && (! empty($this->session->data['order_id']))) { |
|
| 29 | + if (isset($this->session->data['order_id']) && (!empty($this->session->data['order_id']))) { |
|
| 30 | 30 | $this->session->data['last_order_id'] = $this->session->data['order_id']; |
| 31 | 31 | } |
| 32 | 32 | |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | unset($this->session->data['totals']); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - if (! empty($this->session->data['last_order_id'])) { |
|
| 47 | + if (!empty($this->session->data['last_order_id'])) { |
|
| 48 | 48 | $this->document->setTitle(sprintf($this->language->get('heading_title_customer'), $this->session->data['last_order_id'])); |
| 49 | 49 | } else { |
| 50 | 50 | $this->document->setTitle($this->language->get('heading_title')); |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | 'href' => $this->url->link('checkout/success') |
| 73 | 73 | ); |
| 74 | 74 | |
| 75 | - if (! empty($this->session->data['last_order_id'])) { |
|
| 75 | + if (!empty($this->session->data['last_order_id'])) { |
|
| 76 | 76 | $data['heading_title'] = sprintf($this->language->get('heading_title_customer'), $this->session->data['last_order_id']); |
| 77 | 77 | } else { |
| 78 | 78 | $data['heading_title'] = $this->language->get('heading_title'); |
@@ -21,215 +21,215 @@ |
||
| 21 | 21 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
| 22 | 22 | |
| 23 | 23 | class ControllerCheckoutGuestShipping extends \Sunrise\Core\Engine\Controller { |
| 24 | - public function index() { |
|
| 25 | - $this->load->language('checkout/checkout'); |
|
| 26 | - |
|
| 27 | - $data['text_select'] = $this->language->get('text_select'); |
|
| 28 | - $data['text_none'] = $this->language->get('text_none'); |
|
| 29 | - $data['text_loading'] = $this->language->get('text_loading'); |
|
| 30 | - |
|
| 31 | - $data['entry_firstname'] = $this->language->get('entry_firstname'); |
|
| 32 | - $data['entry_lastname'] = $this->language->get('entry_lastname'); |
|
| 33 | - $data['entry_company'] = $this->language->get('entry_company'); |
|
| 34 | - $data['entry_address_1'] = $this->language->get('entry_address_1'); |
|
| 35 | - $data['entry_address_2'] = $this->language->get('entry_address_2'); |
|
| 36 | - $data['entry_postcode'] = $this->language->get('entry_postcode'); |
|
| 37 | - $data['entry_city'] = $this->language->get('entry_city'); |
|
| 38 | - $data['entry_country'] = $this->language->get('entry_country'); |
|
| 39 | - $data['entry_zone'] = $this->language->get('entry_zone'); |
|
| 40 | - |
|
| 41 | - $data['button_continue'] = $this->language->get('button_continue'); |
|
| 42 | - $data['button_upload'] = $this->language->get('button_upload'); |
|
| 43 | - |
|
| 44 | - if (isset($this->session->data['shipping_address']['firstname'])) { |
|
| 45 | - $data['firstname'] = $this->session->data['shipping_address']['firstname']; |
|
| 46 | - } else { |
|
| 47 | - $data['firstname'] = ''; |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - if (isset($this->session->data['shipping_address']['lastname'])) { |
|
| 51 | - $data['lastname'] = $this->session->data['shipping_address']['lastname']; |
|
| 52 | - } else { |
|
| 53 | - $data['lastname'] = ''; |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - if (isset($this->session->data['shipping_address']['company'])) { |
|
| 57 | - $data['company'] = $this->session->data['shipping_address']['company']; |
|
| 58 | - } else { |
|
| 59 | - $data['company'] = ''; |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - if (isset($this->session->data['shipping_address']['address_1'])) { |
|
| 63 | - $data['address_1'] = $this->session->data['shipping_address']['address_1']; |
|
| 64 | - } else { |
|
| 65 | - $data['address_1'] = ''; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - if (isset($this->session->data['shipping_address']['address_2'])) { |
|
| 69 | - $data['address_2'] = $this->session->data['shipping_address']['address_2']; |
|
| 70 | - } else { |
|
| 71 | - $data['address_2'] = ''; |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - if (isset($this->session->data['shipping_address']['postcode'])) { |
|
| 75 | - $data['postcode'] = $this->session->data['shipping_address']['postcode']; |
|
| 76 | - } else { |
|
| 77 | - $data['postcode'] = ''; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - if (isset($this->session->data['shipping_address']['city'])) { |
|
| 81 | - $data['city'] = $this->session->data['shipping_address']['city']; |
|
| 82 | - } else { |
|
| 83 | - $data['city'] = ''; |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - if (isset($this->session->data['shipping_address']['country_id'])) { |
|
| 87 | - $data['country_id'] = $this->session->data['shipping_address']['country_id']; |
|
| 88 | - } else { |
|
| 89 | - $data['country_id'] = $this->config->get('config_country_id'); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - if (isset($this->session->data['shipping_address']['zone_id'])) { |
|
| 93 | - $data['zone_id'] = $this->session->data['shipping_address']['zone_id']; |
|
| 94 | - } else { |
|
| 95 | - $data['zone_id'] = ''; |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - $this->load->model('localisation/country'); |
|
| 99 | - |
|
| 100 | - $data['countries'] = $this->model_localisation_country->getCountries(); |
|
| 101 | - |
|
| 102 | - // Custom Fields |
|
| 103 | - $this->load->model('account/custom_field'); |
|
| 104 | - |
|
| 105 | - $data['custom_fields'] = $this->model_account_custom_field->getCustomFields($this->session->data['guest']['customer_group_id']); |
|
| 106 | - |
|
| 107 | - if (isset($this->session->data['shipping_address']['custom_field'])) { |
|
| 108 | - $data['address_custom_field'] = $this->session->data['shipping_address']['custom_field']; |
|
| 109 | - } else { |
|
| 110 | - $data['address_custom_field'] = array(); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - $this->response->setOutput($this->load->view('checkout/guest_shipping', $data)); |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - public function save() { |
|
| 117 | - $this->load->language('checkout/checkout'); |
|
| 118 | - |
|
| 119 | - $json = array(); |
|
| 120 | - |
|
| 121 | - // Validate if customer is logged in. |
|
| 122 | - if ($this->customer->isLogged()) { |
|
| 123 | - $json['redirect'] = $this->url->link('checkout/checkout', '', true); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - // Validate cart has products and has stock. |
|
| 127 | - if (!$this->cart->hasProducts()) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { |
|
| 128 | - $json['redirect'] = $this->url->link('checkout/cart'); |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - // Check if guest checkout is available. |
|
| 132 | - if (!$this->config->get('config_checkout_guest') || $this->config->get('config_customer_price') || $this->cart->hasDownload()) { |
|
| 133 | - $json['redirect'] = $this->url->link('checkout/checkout', '', true); |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - if (!$json) { |
|
| 137 | - if ((\voku\helper\UTF8::strlen(trim($this->request->post['firstname'])) < 1) || (\voku\helper\UTF8::strlen(trim($this->request->post['firstname'])) > 32)) { |
|
| 138 | - $json['error']['firstname'] = $this->language->get('error_firstname'); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - if ((\voku\helper\UTF8::strlen(trim($this->request->post['lastname'])) < 1) || (\voku\helper\UTF8::strlen(trim($this->request->post['lastname'])) > 32)) { |
|
| 142 | - $json['error']['lastname'] = $this->language->get('error_lastname'); |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - if ((\voku\helper\UTF8::strlen(trim($this->request->post['address_1'])) < 3) || (\voku\helper\UTF8::strlen(trim($this->request->post['address_1'])) > 128)) { |
|
| 146 | - $json['error']['address_1'] = $this->language->get('error_address_1'); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - if ((\voku\helper\UTF8::strlen(trim($this->request->post['city'])) < 2) || (\voku\helper\UTF8::strlen(trim($this->request->post['city'])) > 128)) { |
|
| 150 | - $json['error']['city'] = $this->language->get('error_city'); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - $this->load->model('localisation/country'); |
|
| 154 | - |
|
| 155 | - $country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']); |
|
| 156 | - |
|
| 157 | - if ($country_info && $country_info['postcode_required'] && (\voku\helper\UTF8::strlen(trim($this->request->post['postcode'])) < 2 || \voku\helper\UTF8::strlen(trim($this->request->post['postcode'])) > 10)) { |
|
| 158 | - $json['error']['postcode'] = $this->language->get('error_postcode'); |
|
| 159 | - } |
|
| 24 | + public function index() { |
|
| 25 | + $this->load->language('checkout/checkout'); |
|
| 26 | + |
|
| 27 | + $data['text_select'] = $this->language->get('text_select'); |
|
| 28 | + $data['text_none'] = $this->language->get('text_none'); |
|
| 29 | + $data['text_loading'] = $this->language->get('text_loading'); |
|
| 30 | + |
|
| 31 | + $data['entry_firstname'] = $this->language->get('entry_firstname'); |
|
| 32 | + $data['entry_lastname'] = $this->language->get('entry_lastname'); |
|
| 33 | + $data['entry_company'] = $this->language->get('entry_company'); |
|
| 34 | + $data['entry_address_1'] = $this->language->get('entry_address_1'); |
|
| 35 | + $data['entry_address_2'] = $this->language->get('entry_address_2'); |
|
| 36 | + $data['entry_postcode'] = $this->language->get('entry_postcode'); |
|
| 37 | + $data['entry_city'] = $this->language->get('entry_city'); |
|
| 38 | + $data['entry_country'] = $this->language->get('entry_country'); |
|
| 39 | + $data['entry_zone'] = $this->language->get('entry_zone'); |
|
| 40 | + |
|
| 41 | + $data['button_continue'] = $this->language->get('button_continue'); |
|
| 42 | + $data['button_upload'] = $this->language->get('button_upload'); |
|
| 43 | + |
|
| 44 | + if (isset($this->session->data['shipping_address']['firstname'])) { |
|
| 45 | + $data['firstname'] = $this->session->data['shipping_address']['firstname']; |
|
| 46 | + } else { |
|
| 47 | + $data['firstname'] = ''; |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + if (isset($this->session->data['shipping_address']['lastname'])) { |
|
| 51 | + $data['lastname'] = $this->session->data['shipping_address']['lastname']; |
|
| 52 | + } else { |
|
| 53 | + $data['lastname'] = ''; |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + if (isset($this->session->data['shipping_address']['company'])) { |
|
| 57 | + $data['company'] = $this->session->data['shipping_address']['company']; |
|
| 58 | + } else { |
|
| 59 | + $data['company'] = ''; |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + if (isset($this->session->data['shipping_address']['address_1'])) { |
|
| 63 | + $data['address_1'] = $this->session->data['shipping_address']['address_1']; |
|
| 64 | + } else { |
|
| 65 | + $data['address_1'] = ''; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + if (isset($this->session->data['shipping_address']['address_2'])) { |
|
| 69 | + $data['address_2'] = $this->session->data['shipping_address']['address_2']; |
|
| 70 | + } else { |
|
| 71 | + $data['address_2'] = ''; |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + if (isset($this->session->data['shipping_address']['postcode'])) { |
|
| 75 | + $data['postcode'] = $this->session->data['shipping_address']['postcode']; |
|
| 76 | + } else { |
|
| 77 | + $data['postcode'] = ''; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + if (isset($this->session->data['shipping_address']['city'])) { |
|
| 81 | + $data['city'] = $this->session->data['shipping_address']['city']; |
|
| 82 | + } else { |
|
| 83 | + $data['city'] = ''; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + if (isset($this->session->data['shipping_address']['country_id'])) { |
|
| 87 | + $data['country_id'] = $this->session->data['shipping_address']['country_id']; |
|
| 88 | + } else { |
|
| 89 | + $data['country_id'] = $this->config->get('config_country_id'); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + if (isset($this->session->data['shipping_address']['zone_id'])) { |
|
| 93 | + $data['zone_id'] = $this->session->data['shipping_address']['zone_id']; |
|
| 94 | + } else { |
|
| 95 | + $data['zone_id'] = ''; |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + $this->load->model('localisation/country'); |
|
| 99 | + |
|
| 100 | + $data['countries'] = $this->model_localisation_country->getCountries(); |
|
| 101 | + |
|
| 102 | + // Custom Fields |
|
| 103 | + $this->load->model('account/custom_field'); |
|
| 104 | + |
|
| 105 | + $data['custom_fields'] = $this->model_account_custom_field->getCustomFields($this->session->data['guest']['customer_group_id']); |
|
| 106 | + |
|
| 107 | + if (isset($this->session->data['shipping_address']['custom_field'])) { |
|
| 108 | + $data['address_custom_field'] = $this->session->data['shipping_address']['custom_field']; |
|
| 109 | + } else { |
|
| 110 | + $data['address_custom_field'] = array(); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + $this->response->setOutput($this->load->view('checkout/guest_shipping', $data)); |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + public function save() { |
|
| 117 | + $this->load->language('checkout/checkout'); |
|
| 118 | + |
|
| 119 | + $json = array(); |
|
| 120 | + |
|
| 121 | + // Validate if customer is logged in. |
|
| 122 | + if ($this->customer->isLogged()) { |
|
| 123 | + $json['redirect'] = $this->url->link('checkout/checkout', '', true); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + // Validate cart has products and has stock. |
|
| 127 | + if (!$this->cart->hasProducts()) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { |
|
| 128 | + $json['redirect'] = $this->url->link('checkout/cart'); |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + // Check if guest checkout is available. |
|
| 132 | + if (!$this->config->get('config_checkout_guest') || $this->config->get('config_customer_price') || $this->cart->hasDownload()) { |
|
| 133 | + $json['redirect'] = $this->url->link('checkout/checkout', '', true); |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + if (!$json) { |
|
| 137 | + if ((\voku\helper\UTF8::strlen(trim($this->request->post['firstname'])) < 1) || (\voku\helper\UTF8::strlen(trim($this->request->post['firstname'])) > 32)) { |
|
| 138 | + $json['error']['firstname'] = $this->language->get('error_firstname'); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + if ((\voku\helper\UTF8::strlen(trim($this->request->post['lastname'])) < 1) || (\voku\helper\UTF8::strlen(trim($this->request->post['lastname'])) > 32)) { |
|
| 142 | + $json['error']['lastname'] = $this->language->get('error_lastname'); |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + if ((\voku\helper\UTF8::strlen(trim($this->request->post['address_1'])) < 3) || (\voku\helper\UTF8::strlen(trim($this->request->post['address_1'])) > 128)) { |
|
| 146 | + $json['error']['address_1'] = $this->language->get('error_address_1'); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + if ((\voku\helper\UTF8::strlen(trim($this->request->post['city'])) < 2) || (\voku\helper\UTF8::strlen(trim($this->request->post['city'])) > 128)) { |
|
| 150 | + $json['error']['city'] = $this->language->get('error_city'); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + $this->load->model('localisation/country'); |
|
| 160 | 154 | |
| 161 | - if ($this->request->post['country_id'] == '') { |
|
| 162 | - $json['error']['country'] = $this->language->get('error_country'); |
|
| 163 | - } |
|
| 155 | + $country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']); |
|
| 156 | + |
|
| 157 | + if ($country_info && $country_info['postcode_required'] && (\voku\helper\UTF8::strlen(trim($this->request->post['postcode'])) < 2 || \voku\helper\UTF8::strlen(trim($this->request->post['postcode'])) > 10)) { |
|
| 158 | + $json['error']['postcode'] = $this->language->get('error_postcode'); |
|
| 159 | + } |
|
| 164 | 160 | |
| 165 | - if (!isset($this->request->post['zone_id']) || $this->request->post['zone_id'] == '' || !is_numeric($this->request->post['zone_id'])) { |
|
| 166 | - $json['error']['zone'] = $this->language->get('error_zone'); |
|
| 167 | - } |
|
| 161 | + if ($this->request->post['country_id'] == '') { |
|
| 162 | + $json['error']['country'] = $this->language->get('error_country'); |
|
| 163 | + } |
|
| 168 | 164 | |
| 169 | - // Custom field validation |
|
| 170 | - $this->load->model('account/custom_field'); |
|
| 165 | + if (!isset($this->request->post['zone_id']) || $this->request->post['zone_id'] == '' || !is_numeric($this->request->post['zone_id'])) { |
|
| 166 | + $json['error']['zone'] = $this->language->get('error_zone'); |
|
| 167 | + } |
|
| 171 | 168 | |
| 172 | - $custom_fields = $this->model_account_custom_field->getCustomFields($this->session->data['guest']['customer_group_id']); |
|
| 169 | + // Custom field validation |
|
| 170 | + $this->load->model('account/custom_field'); |
|
| 173 | 171 | |
| 174 | - foreach ($custom_fields as $custom_field) { |
|
| 175 | - if (($custom_field['location'] == 'address') && $custom_field['required'] && empty($this->request->post['custom_field'][$custom_field['custom_field_id']])) { |
|
| 176 | - $json['error']['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']); |
|
| 177 | - } elseif (($custom_field['location'] == 'address') && ($custom_field['type'] == 'text') && !empty($custom_field['validation']) && !filter_var($this->request->post['custom_field'][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $custom_field['validation'])))) { |
|
| 172 | + $custom_fields = $this->model_account_custom_field->getCustomFields($this->session->data['guest']['customer_group_id']); |
|
| 173 | + |
|
| 174 | + foreach ($custom_fields as $custom_field) { |
|
| 175 | + if (($custom_field['location'] == 'address') && $custom_field['required'] && empty($this->request->post['custom_field'][$custom_field['custom_field_id']])) { |
|
| 176 | + $json['error']['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']); |
|
| 177 | + } elseif (($custom_field['location'] == 'address') && ($custom_field['type'] == 'text') && !empty($custom_field['validation']) && !filter_var($this->request->post['custom_field'][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $custom_field['validation'])))) { |
|
| 178 | 178 | $json['error']['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']); |
| 179 | 179 | } |
| 180 | - } |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - if (!$json) { |
|
| 184 | - $this->session->data['shipping_address']['firstname'] = $this->request->post['firstname']; |
|
| 185 | - $this->session->data['shipping_address']['lastname'] = $this->request->post['lastname']; |
|
| 186 | - $this->session->data['shipping_address']['company'] = $this->request->post['company']; |
|
| 187 | - $this->session->data['shipping_address']['address_1'] = $this->request->post['address_1']; |
|
| 188 | - $this->session->data['shipping_address']['address_2'] = $this->request->post['address_2']; |
|
| 189 | - $this->session->data['shipping_address']['postcode'] = $this->request->post['postcode']; |
|
| 190 | - $this->session->data['shipping_address']['city'] = $this->request->post['city']; |
|
| 191 | - $this->session->data['shipping_address']['country_id'] = $this->request->post['country_id']; |
|
| 192 | - $this->session->data['shipping_address']['zone_id'] = $this->request->post['zone_id']; |
|
| 193 | - |
|
| 194 | - $this->load->model('localisation/country'); |
|
| 195 | - |
|
| 196 | - $country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']); |
|
| 197 | - |
|
| 198 | - if ($country_info) { |
|
| 199 | - $this->session->data['shipping_address']['country'] = $country_info['name']; |
|
| 200 | - $this->session->data['shipping_address']['iso_code_2'] = $country_info['iso_code_2']; |
|
| 201 | - $this->session->data['shipping_address']['iso_code_3'] = $country_info['iso_code_3']; |
|
| 202 | - $this->session->data['shipping_address']['address_format'] = $country_info['address_format']; |
|
| 203 | - } else { |
|
| 204 | - $this->session->data['shipping_address']['country'] = ''; |
|
| 205 | - $this->session->data['shipping_address']['iso_code_2'] = ''; |
|
| 206 | - $this->session->data['shipping_address']['iso_code_3'] = ''; |
|
| 207 | - $this->session->data['shipping_address']['address_format'] = ''; |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - $this->load->model('localisation/zone'); |
|
| 211 | - |
|
| 212 | - $zone_info = $this->model_localisation_zone->getZone($this->request->post['zone_id']); |
|
| 213 | - |
|
| 214 | - if ($zone_info) { |
|
| 215 | - $this->session->data['shipping_address']['zone'] = $zone_info['name']; |
|
| 216 | - $this->session->data['shipping_address']['zone_code'] = $zone_info['code']; |
|
| 217 | - } else { |
|
| 218 | - $this->session->data['shipping_address']['zone'] = ''; |
|
| 219 | - $this->session->data['shipping_address']['zone_code'] = ''; |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - if (isset($this->request->post['custom_field'])) { |
|
| 223 | - $this->session->data['shipping_address']['custom_field'] = $this->request->post['custom_field']; |
|
| 224 | - } else { |
|
| 225 | - $this->session->data['shipping_address']['custom_field'] = array(); |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - unset($this->session->data['shipping_method']); |
|
| 229 | - unset($this->session->data['shipping_methods']); |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - $this->response->addHeader('Content-Type: application/json'); |
|
| 233 | - $this->response->setOutput(json_encode($json)); |
|
| 234 | - } |
|
| 180 | + } |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + if (!$json) { |
|
| 184 | + $this->session->data['shipping_address']['firstname'] = $this->request->post['firstname']; |
|
| 185 | + $this->session->data['shipping_address']['lastname'] = $this->request->post['lastname']; |
|
| 186 | + $this->session->data['shipping_address']['company'] = $this->request->post['company']; |
|
| 187 | + $this->session->data['shipping_address']['address_1'] = $this->request->post['address_1']; |
|
| 188 | + $this->session->data['shipping_address']['address_2'] = $this->request->post['address_2']; |
|
| 189 | + $this->session->data['shipping_address']['postcode'] = $this->request->post['postcode']; |
|
| 190 | + $this->session->data['shipping_address']['city'] = $this->request->post['city']; |
|
| 191 | + $this->session->data['shipping_address']['country_id'] = $this->request->post['country_id']; |
|
| 192 | + $this->session->data['shipping_address']['zone_id'] = $this->request->post['zone_id']; |
|
| 193 | + |
|
| 194 | + $this->load->model('localisation/country'); |
|
| 195 | + |
|
| 196 | + $country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']); |
|
| 197 | + |
|
| 198 | + if ($country_info) { |
|
| 199 | + $this->session->data['shipping_address']['country'] = $country_info['name']; |
|
| 200 | + $this->session->data['shipping_address']['iso_code_2'] = $country_info['iso_code_2']; |
|
| 201 | + $this->session->data['shipping_address']['iso_code_3'] = $country_info['iso_code_3']; |
|
| 202 | + $this->session->data['shipping_address']['address_format'] = $country_info['address_format']; |
|
| 203 | + } else { |
|
| 204 | + $this->session->data['shipping_address']['country'] = ''; |
|
| 205 | + $this->session->data['shipping_address']['iso_code_2'] = ''; |
|
| 206 | + $this->session->data['shipping_address']['iso_code_3'] = ''; |
|
| 207 | + $this->session->data['shipping_address']['address_format'] = ''; |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + $this->load->model('localisation/zone'); |
|
| 211 | + |
|
| 212 | + $zone_info = $this->model_localisation_zone->getZone($this->request->post['zone_id']); |
|
| 213 | + |
|
| 214 | + if ($zone_info) { |
|
| 215 | + $this->session->data['shipping_address']['zone'] = $zone_info['name']; |
|
| 216 | + $this->session->data['shipping_address']['zone_code'] = $zone_info['code']; |
|
| 217 | + } else { |
|
| 218 | + $this->session->data['shipping_address']['zone'] = ''; |
|
| 219 | + $this->session->data['shipping_address']['zone_code'] = ''; |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + if (isset($this->request->post['custom_field'])) { |
|
| 223 | + $this->session->data['shipping_address']['custom_field'] = $this->request->post['custom_field']; |
|
| 224 | + } else { |
|
| 225 | + $this->session->data['shipping_address']['custom_field'] = array(); |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + unset($this->session->data['shipping_method']); |
|
| 229 | + unset($this->session->data['shipping_methods']); |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + $this->response->addHeader('Content-Type: application/json'); |
|
| 233 | + $this->response->setOutput(json_encode($json)); |
|
| 234 | + } |
|
| 235 | 235 | } |
| 236 | 236 | \ No newline at end of file |
@@ -124,9 +124,11 @@ |
||
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | // Validate cart has products and has stock. |
| 127 | - if (!$this->cart->hasProducts()) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { |
|
| 127 | + if (!$this->cart->hasProducts()) { |
|
| 128 | + || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { |
|
| 128 | 129 | $json['redirect'] = $this->url->link('checkout/cart'); |
| 129 | 130 | } |
| 131 | + } |
|
| 130 | 132 | |
| 131 | 133 | // Check if guest checkout is available. |
| 132 | 134 | if (!$this->config->get('config_checkout_guest') || $this->config->get('config_customer_price') || $this->cart->hasDownload()) { |
@@ -21,96 +21,96 @@ |
||
| 21 | 21 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
| 22 | 22 | |
| 23 | 23 | class ControllerCheckoutLogin extends \Sunrise\Engine\Core\Controller { |
| 24 | - public function index() { |
|
| 25 | - $this->load->language('checkout/checkout'); |
|
| 24 | + public function index() { |
|
| 25 | + $this->load->language('checkout/checkout'); |
|
| 26 | 26 | |
| 27 | - $data['text_checkout_account'] = $this->language->get('text_checkout_account'); |
|
| 28 | - $data['text_checkout_payment_address'] = $this->language->get('text_checkout_payment_address'); |
|
| 29 | - $data['text_new_customer'] = $this->language->get('text_new_customer'); |
|
| 30 | - $data['text_returning_customer'] = $this->language->get('text_returning_customer'); |
|
| 31 | - $data['text_checkout'] = $this->language->get('text_checkout'); |
|
| 32 | - $data['text_register'] = $this->language->get('text_register'); |
|
| 33 | - $data['text_guest'] = $this->language->get('text_guest'); |
|
| 34 | - $data['text_i_am_returning_customer'] = $this->language->get('text_i_am_returning_customer'); |
|
| 35 | - $data['text_register_account'] = $this->language->get('text_register_account'); |
|
| 36 | - $data['text_forgotten'] = $this->language->get('text_forgotten'); |
|
| 37 | - $data['text_loading'] = $this->language->get('text_loading'); |
|
| 27 | + $data['text_checkout_account'] = $this->language->get('text_checkout_account'); |
|
| 28 | + $data['text_checkout_payment_address'] = $this->language->get('text_checkout_payment_address'); |
|
| 29 | + $data['text_new_customer'] = $this->language->get('text_new_customer'); |
|
| 30 | + $data['text_returning_customer'] = $this->language->get('text_returning_customer'); |
|
| 31 | + $data['text_checkout'] = $this->language->get('text_checkout'); |
|
| 32 | + $data['text_register'] = $this->language->get('text_register'); |
|
| 33 | + $data['text_guest'] = $this->language->get('text_guest'); |
|
| 34 | + $data['text_i_am_returning_customer'] = $this->language->get('text_i_am_returning_customer'); |
|
| 35 | + $data['text_register_account'] = $this->language->get('text_register_account'); |
|
| 36 | + $data['text_forgotten'] = $this->language->get('text_forgotten'); |
|
| 37 | + $data['text_loading'] = $this->language->get('text_loading'); |
|
| 38 | 38 | |
| 39 | - $data['entry_email'] = $this->language->get('entry_email'); |
|
| 40 | - $data['entry_password'] = $this->language->get('entry_password'); |
|
| 39 | + $data['entry_email'] = $this->language->get('entry_email'); |
|
| 40 | + $data['entry_password'] = $this->language->get('entry_password'); |
|
| 41 | 41 | |
| 42 | - $data['button_continue'] = $this->language->get('button_continue'); |
|
| 43 | - $data['button_login'] = $this->language->get('button_login'); |
|
| 42 | + $data['button_continue'] = $this->language->get('button_continue'); |
|
| 43 | + $data['button_login'] = $this->language->get('button_login'); |
|
| 44 | 44 | |
| 45 | - $data['checkout_guest'] = ($this->config->get('config_checkout_guest') && !$this->config->get('config_customer_price') && !$this->cart->hasDownload()); |
|
| 45 | + $data['checkout_guest'] = ($this->config->get('config_checkout_guest') && !$this->config->get('config_customer_price') && !$this->cart->hasDownload()); |
|
| 46 | 46 | |
| 47 | - if (isset($this->session->data['account'])) { |
|
| 48 | - $data['account'] = $this->session->data['account']; |
|
| 49 | - } else { |
|
| 50 | - $data['account'] = 'register'; |
|
| 51 | - } |
|
| 47 | + if (isset($this->session->data['account'])) { |
|
| 48 | + $data['account'] = $this->session->data['account']; |
|
| 49 | + } else { |
|
| 50 | + $data['account'] = 'register'; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - $data['forgotten'] = $this->url->link('account/forgotten', '', true); |
|
| 53 | + $data['forgotten'] = $this->url->link('account/forgotten', '', true); |
|
| 54 | 54 | |
| 55 | - $this->response->setOutput($this->load->view('checkout/login', $data)); |
|
| 56 | - } |
|
| 55 | + $this->response->setOutput($this->load->view('checkout/login', $data)); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - public function save() { |
|
| 59 | - $this->load->language('checkout/checkout'); |
|
| 58 | + public function save() { |
|
| 59 | + $this->load->language('checkout/checkout'); |
|
| 60 | 60 | |
| 61 | - $json = array(); |
|
| 61 | + $json = array(); |
|
| 62 | 62 | |
| 63 | - if ($this->customer->isLogged()) { |
|
| 64 | - $json['redirect'] = $this->url->link('checkout/checkout', '', true); |
|
| 65 | - } |
|
| 63 | + if ($this->customer->isLogged()) { |
|
| 64 | + $json['redirect'] = $this->url->link('checkout/checkout', '', true); |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - if ((!$this->cart->hasProducts()) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { |
|
| 68 | - $json['redirect'] = $this->url->link('checkout/cart'); |
|
| 69 | - } |
|
| 67 | + if ((!$this->cart->hasProducts()) || (!$this->cart->hasStock() && !$this->config->get('config_stock_checkout'))) { |
|
| 68 | + $json['redirect'] = $this->url->link('checkout/cart'); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - if (!$json) { |
|
| 72 | - $this->load->model('account/customer'); |
|
| 71 | + if (!$json) { |
|
| 72 | + $this->load->model('account/customer'); |
|
| 73 | 73 | |
| 74 | - // Check how many login attempts have been made. |
|
| 75 | - $login_info = $this->model_account_customer->getLoginAttempts($this->request->post['email']); |
|
| 74 | + // Check how many login attempts have been made. |
|
| 75 | + $login_info = $this->model_account_customer->getLoginAttempts($this->request->post['email']); |
|
| 76 | 76 | |
| 77 | - if ($login_info && ($login_info['total'] >= $this->config->get('config_login_attempts')) && strtotime('-1 hour') < strtotime($login_info['date_modified'])) { |
|
| 78 | - $json['error']['warning'] = $this->language->get('error_attempts'); |
|
| 79 | - } |
|
| 77 | + if ($login_info && ($login_info['total'] >= $this->config->get('config_login_attempts')) && strtotime('-1 hour') < strtotime($login_info['date_modified'])) { |
|
| 78 | + $json['error']['warning'] = $this->language->get('error_attempts'); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - // Check if customer has been approved. |
|
| 82 | - $customer_info = $this->model_account_customer->getCustomerByEmail($this->request->post['email']); |
|
| 81 | + // Check if customer has been approved. |
|
| 82 | + $customer_info = $this->model_account_customer->getCustomerByEmail($this->request->post['email']); |
|
| 83 | 83 | |
| 84 | - if ($customer_info && !$customer_info['approved']) { |
|
| 85 | - $json['error']['warning'] = $this->language->get('error_approved'); |
|
| 86 | - } |
|
| 84 | + if ($customer_info && !$customer_info['approved']) { |
|
| 85 | + $json['error']['warning'] = $this->language->get('error_approved'); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - if (!isset($json['error'])) { |
|
| 89 | - if (!$this->customer->login($this->request->post['email'], $this->request->post['password'])) { |
|
| 90 | - $json['error']['warning'] = $this->language->get('error_login'); |
|
| 88 | + if (!isset($json['error'])) { |
|
| 89 | + if (!$this->customer->login($this->request->post['email'], $this->request->post['password'])) { |
|
| 90 | + $json['error']['warning'] = $this->language->get('error_login'); |
|
| 91 | 91 | |
| 92 | - $this->model_account_customer->addLoginAttempt($this->request->post['email']); |
|
| 93 | - } else { |
|
| 94 | - $this->model_account_customer->deleteLoginAttempts($this->request->post['email']); |
|
| 95 | - } |
|
| 96 | - } |
|
| 97 | - } |
|
| 92 | + $this->model_account_customer->addLoginAttempt($this->request->post['email']); |
|
| 93 | + } else { |
|
| 94 | + $this->model_account_customer->deleteLoginAttempts($this->request->post['email']); |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - if (!$json) { |
|
| 100 | - // Unset guest |
|
| 101 | - unset($this->session->data['guest']); |
|
| 99 | + if (!$json) { |
|
| 100 | + // Unset guest |
|
| 101 | + unset($this->session->data['guest']); |
|
| 102 | 102 | |
| 103 | - // Default Shipping Address |
|
| 104 | - $this->load->model('account/address'); |
|
| 103 | + // Default Shipping Address |
|
| 104 | + $this->load->model('account/address'); |
|
| 105 | 105 | |
| 106 | - $this->session->data['payment_address'] = $this->model_account_address->getAddress($this->customer->getAddressId()); |
|
| 106 | + $this->session->data['payment_address'] = $this->model_account_address->getAddress($this->customer->getAddressId()); |
|
| 107 | 107 | |
| 108 | - $this->session->data['shipping_address'] = $this->model_account_address->getAddress($this->customer->getAddressId()); |
|
| 108 | + $this->session->data['shipping_address'] = $this->model_account_address->getAddress($this->customer->getAddressId()); |
|
| 109 | 109 | |
| 110 | - $json['redirect'] = $this->url->link('checkout/checkout', '', true); |
|
| 111 | - } |
|
| 110 | + $json['redirect'] = $this->url->link('checkout/checkout', '', true); |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - $this->response->addHeader('Content-Type: application/json'); |
|
| 114 | - $this->response->setOutput(json_encode($json)); |
|
| 115 | - } |
|
| 113 | + $this->response->addHeader('Content-Type: application/json'); |
|
| 114 | + $this->response->setOutput(json_encode($json)); |
|
| 115 | + } |
|
| 116 | 116 | } |