$redirect = true; $anchor = 'taxrules'; } if ($updated) { ## Generic message as a few things can be updated at once $GLOBALS['main']->setACPNotify($lang['settings']['notify_tax_updated']); } if ($redirect) { httpredir(currentPage(array('delete_class', 'delete_detail', 'delete_rule')), $anchor); } ############################################################### ## Get countries if (($countries = $GLOBALS['db']->select('CubeCart_geo_country', array('numcode', 'name'))) !== false) { $GLOBALS['smarty']->assign('COUNTRIES', $countries); ## Get counties $GLOBALS['smarty']->assign('VAL_JSON_COUNTY', state_json()); $GLOBALS['smarty']->assign('CONFIG', $GLOBALS['config']->get('config')); } ## Get Tax Classes if (($tax_classes = $GLOBALS['db']->select('CubeCart_tax_class')) !== false) { $GLOBALS['smarty']->assign('TAX_CLASSES', $tax_classes); foreach ($tax_classes as $class) { $tax_class[$class['id']] = $class['tax_name']; } } ## Get Tax Details if (($tax_details = $GLOBALS['db']->select('CubeCart_tax_details')) !== false) { foreach ($tax_details as $tax_detail) { if ($tax_detail['status']) { $tax_detail['enabled'] = 'selected="selected"'; } else {
} } for ($i = 1; $i <= 6; ++$i) { $smarty_data['order_status'][] = array('id' => $i, 'selected' => isset($summary[0]) && isset($summary[0]['status']) && (int) $summary[0]['status'] === $i ? ' selected="selected"' : '', 'string' => $lang['order_state']['name_' . $i]); } $GLOBALS['smarty']->assign('LIST_ORDER_STATUS', $smarty_data['order_status']); if (($countries = $GLOBALS['db']->select('CubeCart_geo_country')) !== false) { $store_country = $GLOBALS['config']->get('config', 'store_country'); foreach ($countries as $country) { $country['is_billing'] = isset($summary[0]) && isset($summary[0]['country']) && $country['numcode'] == $summary[0]['country'] ? ' selected="selected"' : ''; $country['selected'] = !isset($summary[0]) || !isset($summary[0]['country']) && $country['numcode'] == $store_country ? ' selected="selected"' : ''; $country['is_delivery'] = isset($summary[0]) && isset($summary[0]['country_d']) && $country['numcode'] == $summary[0]['country_d'] ? ' selected="selected"' : ''; $smarty_data['list_country'][] = $country; } $GLOBALS['smarty']->assign('LIST_COUNTRY', $smarty_data['list_country']); $GLOBALS['smarty']->assign('STATE_JSON', state_json()); } // Hook foreach ($GLOBALS['hooks']->load('admin.order.index.display') as $hook) { include $hook; } $GLOBALS['smarty']->assign('PLUGIN_TABS', $smarty_data['plugin_tabs']); $GLOBALS['smarty']->assign('DISPLAY_FORM', true); } else { if (isset($_GET['print']) && !empty($_GET['print'])) { // Generate a printable page, and display it // Made somewhat trickier by the way the templating system works // so we'll generate the page, stick it in the cache folder, trigger the print, then delete the file foreach ($_GET['print'] as $order_id) { $order_list[] = "'" . $order_id . "'"; }
/** * Display checkout */ private function _checkout() { // Update basket if we need to! $GLOBALS['cart']->update(); $GLOBALS['smarty']->assign('URL', array('login' => $GLOBALS['seo']->buildURL('login'))); $GLOBALS['smarty']->assign('INCLUDE_CHECKOUT', true); $this->_basket =& $GLOBALS['cart']->basket; if (isset($_POST['comments']) && !empty($_POST['comments'])) { $this->_basket['comments'] = strip_tags(urldecode($_POST['comments'])); $GLOBALS['cart']->save(); } $GLOBALS['smarty']->assign('VAL_CUSTOMER_COMMENTS', isset($this->_basket['comments']) ? $this->_basket['comments'] : ''); foreach ($GLOBALS['hooks']->load('class.cubecart.construct.confirm') as $hook) { include $hook; } // Display order confirmation page if (!$GLOBALS['user']->is()) { // Unregistered Users if (!isset($this->_basket['register'])) { $this->_basket['register'] = true; } if (!isset($_POST['username']) && isset($_POST['user']) && isset($_POST['billing'])) { $proceed = true; $optional = array('mobile', 'line2'); $handle_post = array('user' => 'customer', 'billing' => 'billing_address', 'delivery' => 'delivery_address'); foreach ($_POST as $index => $data) { if (!in_array($index, $handle_post)) { continue; } $missing_field = false; foreach ($data as $key => $value) { if (!in_array($key, $optional) && empty($value)) { $proceed = false; $missing_field = true; } } } if ($missing_field) { $GLOBALS['gui']->setError($GLOBALS['language']->common['error_fields_required']); } // Check T&C's have been agreed to if (!$GLOBALS['config']->get('config', 'disable_checkout_terms') && $GLOBALS['db']->select('CubeCart_documents', false, array('doc_terms' => '1')) !== false && !isset($_POST['terms_agree'])) { $GLOBALS['gui']->setError($GLOBALS['language']->account['error_terms_agree']); $errors['terms_agree'] = true; } elseif ($_POST['terms_agree']) { $this->_basket['terms_agree'] = true; } // Handle user data, and put into the basket array $this->_basket['customer'] = $_POST['user']; $old_addresses = md5(serialize(array_merge($this->_basket['billing_address'], $this->_basket['delivery_address']))); $this->_basket['billing_address'] = array('user_defined' => true, 'title' => $_POST['user']['title'], 'first_name' => $_POST['user']['first_name'], 'last_name' => $_POST['user']['last_name'], 'company_name' => $_POST['billing']['company_name'], 'line1' => $_POST['billing']['line1'], 'line2' => $_POST['billing']['line2'], 'town' => $_POST['billing']['town'], 'postcode' => $_POST['billing']['postcode'], 'state_id' => $_POST['billing']['state'], 'state' => getStateFormat($_POST['billing']['state'], 'id', 'name'), 'state_abbrev' => getStateFormat($_POST['billing']['state'], 'id', 'abbrev'), 'country' => $_POST['billing']['country'], 'country_id' => $_POST['billing']['country'], 'country_iso' => getCountryFormat($_POST['billing']['country'], 'numcode', 'iso'), 'country_name' => getCountryFormat($_POST['billing']['country'], 'numcode', 'name')); if (isset($_POST['delivery']) && !isset($_POST['delivery_is_billing'])) { $this->_basket['delivery_address'] = array('user_defined' => true, 'title' => $_POST['delivery']['title'], 'first_name' => $_POST['delivery']['first_name'], 'last_name' => $_POST['delivery']['last_name'], 'company_name' => $_POST['delivery']['company_name'], 'line1' => $_POST['delivery']['line1'], 'line2' => $_POST['delivery']['line2'], 'town' => $_POST['delivery']['town'], 'postcode' => $_POST['delivery']['postcode'], 'state_id' => $_POST['delivery']['state'], 'state' => getStateFormat($_POST['delivery']['state'], 'id', 'name'), 'state_abbrev' => getStateFormat($_POST['delivery']['state'], 'id', 'abbrev'), 'country' => $_POST['delivery']['country'], 'country_id' => $_POST['delivery']['country'], 'country_iso' => getCountryFormat($_POST['delivery']['country'], 'numcode', 'iso'), 'country_name' => getCountryFormat($_POST['delivery']['country'], 'numcode', 'name')); } else { $this->_basket['delivery_address'] = $this->_basket['billing_address']; } $this->_basket['delivery_address']['is_billing'] = isset($_POST['delivery_is_billing']) ? true : false; $new_addresses = md5(serialize(array_merge($this->_basket['billing_address'], $this->_basket['delivery_address']))); if ($new_addresses !== $old_addresses) { // Set notice to prevent proceed to payment screen $GLOBALS['gui']->setNotify($GLOBALS['language']->account["notify_address_updated"]); } if ($GLOBALS['config']->get('config', 'recaptcha') && !$GLOBALS['session']->get('confirmed', 'recaptcha')) { if (($message = $GLOBALS['session']->get('error', 'recaptcha')) === false) { //If the error message from recaptcha fails for some reason: $error_messages[] = $GLOBALS['language']->form['verify_human_fail']; } else { $error_messages[] = $GLOBALS['session']->get('error', 'recaptcha'); } $errors['recaptcha'] = true; } // Check email is valid if (!filter_var($_POST['user']['email'], FILTER_VALIDATE_EMAIL)) { $errors['email'] = true; $error_messages[] = $GLOBALS['language']->common['error_email_invalid']; } // Check email is not in use if ($GLOBALS['db']->select('CubeCart_customer', array('email'), array('email' => $_POST['user']['email'], 'type' => 1))) { // Email in use $errors['email'] = true; $error_messages[] = $GLOBALS['language']->account['error_email_in_use']; } // Check passwords match if not empty if (isset($_POST['register']) && $_POST['register'] == 1 && !empty($_POST['password']) && $_POST['password'] !== $_POST['passconf']) { $errors['password'] = true; $error_messages[] = $GLOBALS['language']->account['error_password_mismatch']; } if (preg_match("/[a-z]/i", $_POST['user']['phone'])) { $errors['phone'] = true; $error_messages[] = $GLOBALS['language']->account['error_valid_phone']; } if (!empty($_POST['user']['mobile']) && preg_match("/[a-z]/i", $_POST['user']['mobile'])) { $errors['phone'] = true; $error_messages[] = $GLOBALS['language']->account['error_valid_mobile_phone']; } if (is_array($error_messages)) { $GLOBALS['gui']->setError($error_messages); } if (!isset($errors)) { // Create the user account $_POST['user']['password'] = isset($_POST['register']) && $_POST['register'] == 1 ? md5($_POST['password']) : md5(time() . $SERVER['HTTP_USER_AGENT'] . $_SERVER['REMOTE_ADDR']); $type = isset($_POST['register']) && $_POST['register'] == 1 ? 1 : 2; $user_id = $GLOBALS['user']->createUser($_POST['user'], false, $type); $this->_basket['customer']['customer_id'] = $user_id; // Insert a new BILLING address $address = array('customer_id' => $user_id, 'billing' => true, 'default' => isset($_POST['delivery']) ? false : true, 'title' => $this->_basket['customer']['title'], 'first_name' => $this->_basket['customer']['first_name'], 'last_name' => $this->_basket['customer']['last_name'], 'description' => $GLOBALS['language']->address['default_billing_address']); $GLOBALS['user']->saveAddress(array_merge($this->_basket['billing_address'], $address), $user_id); // Insert a new DELIVERY address $address = array('customer_id' => $user_id, 'billing' => false, 'default' => true, 'description' => $GLOBALS['language']->address['default_delivery_address']); $GLOBALS['user']->saveAddress(array_merge($this->_basket['delivery_address'], $address), $user_id); foreach ($GLOBALS['hooks']->load('class.cubecart.construct.confirm.create_user.created') as $hook) { include $hook; } // Log in $GLOBALS['session']->set('redir', $GLOBALS['rootRel'] . 'index.php?_a=confirm'); if (isset($_POST['register']) && $_POST['register'] == 1 && !$GLOBALS['user']->authenticate($_POST['user']['email'], $_POST['password'], false, false, false, false)) { httpredir('index.php?_a=login'); } } if (isset($_POST['register']) && $_POST['register'] == 1) { $this->_basket['register'] = true; } else { $this->_basket['register'] = false; } if (isset($errors) && is_array($errors)) { foreach ($errors as $parent => $error) { if (is_array($error)) { foreach ($error as $key => $value) { unset($this->_basket[$parent][$key]); } } } } $GLOBALS['cart']->save(); } $GLOBALS['smarty']->assign('ALLOW_DELIVERY_ADDRESS', $GLOBALS['config']->get('config', 'basket_allow_non_invoice_address') && !$GLOBALS['cart']->getBasketDigital()); if (isset($this->_basket['customer'])) { $GLOBALS['smarty']->assign('USER', $this->_basket['customer']); } if (isset($this->_basket['billing_address']) && $this->_basket['billing_address']['user_defined'] || $this->_basket['billing_address']['estimate']) { $GLOBALS['smarty']->assign('BILLING', $this->_basket['billing_address']); } if (isset($this->_basket['delivery_address']) && $this->_basket['delivery_address']['user_defined'] || $this->_basket['delivery_address']['estimate']) { $GLOBALS['smarty']->assign('DELIVERY', $this->_basket['delivery_address']); } // @todo fix this - should auto select on first load if (!isset($this->_basket['delivery_address']['is_billing']) || $this->_basket['delivery_address']['is_billing']) { $GLOBALS['smarty']->assign('DELIVERY_CHECKED', 'checked="checked"'); } // Parse page elements if (($countries = $GLOBALS['db']->select('CubeCart_geo_country', array('numcode', 'name'), array('status' => 1), array('name' => 'ASC'))) !== false) { foreach ($countries as $country) { $country['selected'] = ''; if (isset($this->_basket['billing_address']['country_id']) && !empty($this->_basket['billing_address']['country_id'])) { if ($country['numcode'] == $this->_basket['billing_address']['country_id']) { $country['selected'] = 'selected="selected"'; } } else { if ($country['numcode'] == $GLOBALS['config']->get('config', 'store_country')) { $country['selected'] = 'selected="selected"'; } } $country['selected_d'] = ''; if (isset($this->_basket['delivery_address']['country_id']) && !empty($this->_basket['delivery_address']['country_id'])) { if ($country['numcode'] == $this->_basket['delivery_address']['country_id']) { $country['selected_d'] = 'selected="selected"'; } } else { if ($country['numcode'] == $GLOBALS['config']->get('config', 'store_country')) { $country['selected_d'] = 'selected="selected"'; } } $GLOBALS['smarty']->append('COUNTRIES', $country); } $GLOBALS['smarty']->assign('STATE_JSON', state_json()); } foreach ($GLOBALS['hooks']->load('class.cubecart.prerecaptcha.confirm') as $hook) { include $hook; } if (!isset($this->_basket['recaptcha'])) { $recaptcha = $GLOBALS['config']->get('config', 'recaptcha'); if ($recaptcha == 2) { $GLOBALS['smarty']->assign('RECAPTCHA', $recaptcha); } else { $GLOBALS['smarty']->assign('LANG_RECAPTCHA', array('reload_words' => sprintf($GLOBALS['language']->recaptcha['reload_words'], 'javascript:Recaptcha.reload()', "javascript:Recaptcha.switch_type('audio')"), 'reload_numbers' => sprintf($GLOBALS['language']->recaptcha['reload_numbers'], 'javascript:Recaptcha.reload()', "javascript:Recaptcha.switch_type('image')"))); if ($GLOBALS['config']->get('config', 'recaptcha') && !$GLOBALS['session']->get('confirmed', 'recaptcha')) { $GLOBALS['smarty']->assign('DISPLAY_RECAPTCHA', recaptcha_get_html($GLOBALS['recaptcha_keys']['captcha_public'], $GLOBALS['recaptcha']['error'], CC_SSL)); $GLOBALS['smarty']->assign('RECAPTCHA', true); } } } $GLOBALS['smarty']->assign('TERMS_CONDITIONS', !$GLOBALS['config']->get('config', 'disable_checkout_terms') && ($terms = $GLOBALS['db']->select('CubeCart_documents', false, array('doc_terms' => '1'))) ? $GLOBALS['seo']->buildURL('doc', $terms[0]['doc_id'], '&') : false); if (isset($_POST['terms_agree']) && $_POST['terms_agree'] == 1) { $this->_basket['terms_agree'] = true; } if (isset($_POST['mailing_list']) && $_POST['mailing_list'] == 1) { $this->_basket['mailing_list'] = true; $newsletter = Newsletter::getInstance(); $newsletter->subscribe($this->_basket['customer']['email']); } $GLOBALS['smarty']->assign('REGISTER_CHECKED', isset($this->_basket['register']) && $this->_basket['register'] ? 'checked="checked"' : ''); $GLOBALS['smarty']->assign('TERMS_CONDITIONS_CHECKED', isset($this->_basket['terms_agree']) && $this->_basket['terms_agree'] ? 'checked="checked"' : ''); $GLOBALS['smarty']->assign('MAILING_LIST_SUBSCRIBE', isset($this->_basket['terms_agree']) && $this->_basket['terms_agree'] ? 'checked="checked"' : ''); } else { // Registered users - Display predefined addresses, if any exist $this->_displayAddresses(); } }