Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Code: Select all
$this->setShippingAddress((isset($address_query->row['country_id']) ? $address_query->row['country_id'] : 0), (isset($address_query->row['zone_id']) ? $address_query->row['zone_id'] : 0);
Correct code:
Code: Select all
$this->setShippingAddress((isset($address_query->row['country_id']) ? $address_query->row['country_id'] : 0), (isset($address_query->row['zone_id']) ? $address_query->row['zone_id'] : 0));
Reason: wrap the code
from my searching so far it seems to be related to left over incomplete data in $this->session->data['guest']
my above post on re uploading that file did not end up working. here is what i found and my system has been good for weeks without setting up a tax.
the issue i hit ended up being a user was created without an address and when i went to checkout the tax error surfaced. i created an address for that customer and the issue went away after i cleared the cache.
a little later i hit the tax error again after i imported some customers into 1513. the customer info from 1495 was imported correctly including the address however the first and last name was blank on the address in that it was optional on 1495 but required fields on 1513. i updated all my imported customers so their address had their first and last name and i have not hit the tax error since.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Logged out of admin, refreshed the store page and the error was gone. Logged back into admin and it was still fine. I'm assuming it had something to do with the fact that as admin I was registered with the same email as the test account.
I have no idea what exactly happened, total noob, but maybe a similar scenario may have contributed to the problems experienced by others.
With all that being said, perhaps the OC team thought of this as a limited feature the admin would have to re-use the email address or perhaps this issue was simply never addressed before. On either case, since there are no specific rule stating that customers may have to be prevented of knowing an already existing email address upon registration as long as it doesn't state specifically to whom it is designated to, the following solution should be used:
In admin/controller/sale/customer.php file,
find twice:
Code: Select all
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
Code: Select all
$this->load->model('user/user');
Code: Select all
if ((utf8_strlen($this->request->post['telephone']) < 3) || (utf8_strlen($this->request->post['telephone']) > 32)) {
Code: Select all
$admin_info = $this->model_user_user->getTotalUsersByEmail($this->request->post['email']);
if (!isset($this->request->get['customer_id'])) {
if ($admin_info) {
$this->error['warning'] = $this->language->get('error_admin_exists');
}
} else {
if ($admin_info && ($this->request->get['customer_id'] != $admin_info['customer_id'])) {
$this->error['warning'] = $this->language->get('error_admin_exists');
}
}
find:
Code: Select all
$_['error_exists']
Code: Select all
$_['error_admin_exists'] = 'Warning: Admin E-Mail Address is already registered!';
In admin/controller/user/user.php file,
find twice:
Code: Select all
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
Code: Select all
$this->load->model('sale/customer');
Code: Select all
if ($this->request->post['password'] || (!isset($this->request->get['user_id']))) {
Code: Select all
if ((utf8_strlen($this->request->post['email']) > 96) || !preg_match('/^[^\@]+@.*\.[a-z]{2,6}$/i', $this->request->post['email'])) {
$this->error['email'] = $this->language->get('error_email');
} elseif ($this->model_user_user->getTotalUsersByEmail($this->request->post['email'])) {
$this->error['email'] = $this->language->get('error_email');
} elseif ($this->model_sale_customer->getTotalCustomersByEmail($this->request->post['email'])) {
$this->error['email'] = $this->language->get('error_email');
}
Code: Select all
$this->data['error_lastname'] = '';
}
Code: Select all
if (isset($this->error['email'])) {
$this->data['error_email'] = $this->error['email'];
} else {
$this->data['error_email'] = '';
}
find:
Code: Select all
$_['error_lastname']
Code: Select all
$_['error_email'] = 'Email address already exists!';
find:
Code: Select all
if ($this->model_account_customer->getTotalCustomersByEmail($this->request->post['email'])) {
$this->error['warning'] = $this->language->get('error_exists');
}
Code: Select all
if ($this->model_account_customer->getTotalCustomersByEmail($this->request->post['email'])) {
$this->error['warning'] = $this->language->get('error_exists');
} elseif ($this->model_account_customer->getTotalUsersByEmail($this->request->post['email'])) {
$this->error['warning'] = $this->language->get('error_exists');
}
find:
Code: Select all
public function getTotalCustomersByEmail($email) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "customer WHERE email = '" . $this->db->escape($email) . "'");
return $query->row['total'];
}
Code: Select all
public function getTotaUsersByEmail($email) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "user WHERE email = '" . $this->db->escape($email) . "'");
return $query->row['total'];
}
find:
Code: Select all
if ($this->model_account_customer->getTotalCustomersByEmail($this->request->post['email'])) {
$json['error']['warning'] = $this->language->get('error_exists');
}
Code: Select all
if ($this->model_account_customer->getTotalCustomersByEmail($this->request->post['email'])) {
$json['error']['warning'] = $this->language->get('error_exists');
} elseif ($this->model_account_customer->getTotalUsersByEmail($this->request->post['email'])) {
$json['error']['warning'] = $this->language->get('error_exists');
}
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Prior to doing the testing and deleting the customer, last night I deleted some of the zones because I am trying to cut it down to the U.S. I did not delete the U.S. or any of its states.
After deleting the customer this afternoon is when i started getting the error message. I cannot go much in the cart now and do not know how to fix the problem.
Please help....Thanks!
replace all instances of:
Code: Select all
$this->setShippingAddress($address_query->row['country_id'], $address_query->row['zone_id']);
Code: Select all
if ($address_query->num_rows) {
$this->setShippingAddress($address_query->row['country_id'], $address_query->row['zone_id']);
}
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
These are the errors I have in my log:
2013-01-30 21:57:28 - PHP Notice: Undefined index: zone_id in /var/www/vhosts/7/xxxxx/webspace/httpdocs/pretzel-shop.com/catalog/controller/account/register.php on line 423
2013-01-30 22:05:12 - PHP Notice: Undefined index: company_id in /var/www/vhosts/7/xxxxx/webspace/httpdocs/pretzel-shop.com/catalog/controller/checkout/guest.php on line 269
2013-01-30 22:05:12 - PHP Notice: Undefined index: tax_id in /var/www/vhosts/7/xxxxxx/webspace/httpdocs/pretzel-shop.com/catalog/controller/checkout/guest.php on line 270
I am running open cart 1.5.4
Please help me with this because there is nobody that can check out in any way.
No guest check outs
No account registers
I need to fix this ASAP!
Code: Select all
PHP Notice: Undefined index: zone_id in /home/XXXXXXXX/public_html/catalog/controller/account/register.php on line 423
Code: Select all
if ($this->request->post['zone_id'] == '') {
$this->error['zone'] = $this->language->get('error_zone');
My store upgraded from 1.5.3.1 to 1.5.4
Code: Select all
Line 77 = $this->data['entry_account'] = $this->language->get('entry_account');
Line 384 = if ($customer_group['company_id_display'] && $customer_group['company_id_required'] && !$this->request->post['company_id']) {
Line 389 = if ($customer_group['tax_id_display'] && $customer_group['tax_id_required'] && !$this->request->post['tax_id']) {
Line 414 = if ($this->config->get('config_vat') && $this->request->post['tax_id'] && (vat_validation($country_info['iso_code_2'], $this->request->post['tax_id']) != 'invalid')) {
Code: Select all
Line 77 = $this->data['entry_customer_group'] = $this->language->get('entry_customer_group');
Line 384 = if ($customer_group['company_id_display'] && $customer_group['company_id_required'] && empty($this->request->post['company_id'])) {
Line 389 = if ($customer_group['tax_id_display'] && $customer_group['tax_id_required'] && empty($this->request->post['tax_id'])) {
Line 414 = if ($this->config->get('config_vat') && $this->request->post['tax_id'] && (vat_validation($country_info['iso_code_2'], $this->request->post['tax_id']) == 'invalid')) {
Well I'm suppose to have version 1.5.4 because I paid someone to make the update for me
If I do replace it is there any other file that I need to change to make sure I won't get no more error?
Tks
Cleo
Opencart v1.5.4.1 fr/en
Theme: Custom
vqmod-2.6.0
PHP: 7.3 (ea-php73)
Code: Select all
if ($this->request->post['zone_id'] == '') {
Code: Select all
if (empty($this->request->post['zone_id'])) {
Code: Select all
if ($this->config->get('config_vat') && $this->request->post['tax_id'] && (vat_validation($country_info['iso_code_2'], $this->request->post['tax_id']) == 'invalid')) {
Code: Select all
if ($this->config->get('config_vat') && !empty($this->request->post['tax_id']) && (vat_validation($country_info['iso_code_2'], $this->request->post['tax_id']) == 'invalid')) {
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
I realize this post is a bit old, but I am experiencing the same problem, and tried everything mentioned here, with no result.
My store has been up for a while, we are in the process of adding some fonctiunalities, so this morning, before adding the new extensions, I made a backup of my database.
I installed one extension, wanted to test it out and logged my self in as a customer with the same email as my admin email, not knowing it would cause problems. I had some addresses in there that were missing some provinces/states and then I got the undefined errors.
So I ended up here, tried all the solutions listed here and removing my new extension, just in case. After adding the missing provinces/states, there errors went away. Adding/removing the extension didn't change anything.
Now nobody can checkout, because we can't get to step4, delivery method. If anybody could suggest anything, it would be greatly appreciated!
Just in case, here is my system/library/tax.php file:
Code: Select all
<?php
final class Tax {
private $shipping_address;
private $payment_address;
private $store_address;
public function __construct($registry) {
$this->config = $registry->get('config');
$this->customer = $registry->get('customer');
$this->db = $registry->get('db');
$this->session = $registry->get('session');
// If shipping address is being used
if (isset($this->session->data['shipping_address_id'])) {
$address_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "address WHERE address_id = '" . (int)$this->session->data['shipping_address_id'] . "'");
// $this->setShippingAddress($address_query->row['country_id'], $address_query->row['zone_id']);
$this->setShippingAddress((isset($address_query->row['country_id']) ? $address_query->row['country_id'] : 0), (isset($address_query->row['zone_id']) ? $address_query->row['zone_id'] : 0));
} elseif (isset($this->session->data['guest']['shipping'])) {
$this->setShippingAddress($this->session->data['guest']['shipping']['country_id'], $this->session->data['guest']['shipping']['zone_id']);
} elseif ($this->customer->isLogged() && ($this->config->get('config_tax_customer') == 'shipping')) {
$address_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "address WHERE address_id = '" . (int)$this->customer->getAddressId() . "'");
// $this->setShippingAddress($address_query->row['country_id'], $address_query->row['zone_id']);
$this->setShippingAddress((isset($address_query->row['country_id']) ? $address_query->row['country_id'] : 0), (isset($address_query->row['zone_id']) ? $address_query->row['zone_id'] : 0));
} elseif ($this->config->get('config_tax_default') == 'shipping') {
$this->setShippingAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id'));
}
if (isset($this->session->data['payment_address_id'])) {
$address_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "address WHERE address_id = '" . (int)$this->session->data['payment_address_id'] . "'");
$this->setPaymentAddress($address_query->row['country_id'], $address_query->row['zone_id']);
} elseif (isset($this->session->data['guest']['payment'])) {
$this->setPaymentAddress($this->session->data['guest']['payment']['country_id'], $this->session->data['guest']['payment']['zone_id']);
} elseif ($this->customer->isLogged() && ($this->config->get('config_tax_customer') == 'payment')) {
$address_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "address WHERE address_id = '" . (int)$this->customer->getAddressId() . "'");
$this->setPaymentAddress($address_query->row['country_id'], $address_query->row['zone_id']);
} elseif ($this->config->get('config_tax_default') == 'payment') {
$this->setPaymentAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id'));
}
$this->setStoreAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id'));
}
public function setShippingAddress($country_id, $zone_id) {
$this->shipping_address = array(
'country_id' => $country_id,
'zone_id' => $zone_id
);
}
public function setPaymentAddress($country_id, $zone_id) {
$this->payment_address = array(
'country_id' => $country_id,
'zone_id' => $zone_id
);
}
public function setStoreAddress($country_id, $zone_id) {
$this->store_address = array(
'country_id' => $country_id,
'zone_id' => $zone_id
);
}
public function calculate($value, $tax_class_id, $calculate = true) {
if ($tax_class_id && $calculate) {
$amount = $this->getTax($value, $tax_class_id);
return $value + $amount;
} else {
return $value;
}
}
public function getTax($value, $tax_class_id) {
$amount = 0;
$tax_rates = $this->getRates($value, $tax_class_id);
foreach ($tax_rates as $tax_rate) {
$amount += $tax_rate['amount'];
}
return $amount;
}
public function getRateName($tax_rate_id) {
$tax_query = $this->db->query("SELECT name FROM " . DB_PREFIX . "tax_rate WHERE tax_rate_id = '" . (int)$tax_rate_id . "'");
if ($tax_query->num_rows) {
return $tax_query->row['name'];
} else {
return false;
}
}
public function getRates($value, $tax_class_id) {
$tax_rates = array();
if ($this->customer->isLogged()) {
$customer_group_id = $this->customer->getCustomerGroupId();
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}
if ($this->shipping_address) {
$tax_query = $this->db->query("SELECT tr2.tax_rate_id, tr2.name, tr2.rate, tr2.type, tr1.priority FROM " . DB_PREFIX . "tax_rule tr1 LEFT JOIN " . DB_PREFIX . "tax_rate tr2 ON (tr1.tax_rate_id = tr2.tax_rate_id) INNER JOIN " . DB_PREFIX . "tax_rate_to_customer_group tr2cg ON (tr2.tax_rate_id = tr2cg.tax_rate_id) LEFT JOIN " . DB_PREFIX . "zone_to_geo_zone z2gz ON (tr2.geo_zone_id = z2gz.geo_zone_id) LEFT JOIN " . DB_PREFIX . "geo_zone gz ON (tr2.geo_zone_id = gz.geo_zone_id) WHERE tr1.tax_class_id = '" . (int)$tax_class_id . "' AND tr1.based = 'shipping' AND tr2cg.customer_group_id = '" . (int)$customer_group_id . "' AND z2gz.country_id = '" . (int)$this->shipping_address['country_id'] . "' AND (z2gz.zone_id = '0' OR z2gz.zone_id = '" . (int)$this->shipping_address['zone_id'] . "') ORDER BY tr1.priority ASC");
foreach ($tax_query->rows as $result) {
$tax_rates[$result['tax_rate_id']] = array(
'tax_rate_id' => $result['tax_rate_id'],
'name' => $result['name'],
'rate' => $result['rate'],
'type' => $result['type'],
'priority' => $result['priority']
);
}
}
if ($this->payment_address) {
$tax_query = $this->db->query("SELECT tr2.tax_rate_id, tr2.name, tr2.rate, tr2.type, tr1.priority FROM " . DB_PREFIX . "tax_rule tr1 LEFT JOIN " . DB_PREFIX . "tax_rate tr2 ON (tr1.tax_rate_id = tr2.tax_rate_id) INNER JOIN " . DB_PREFIX . "tax_rate_to_customer_group tr2cg ON (tr2.tax_rate_id = tr2cg.tax_rate_id) LEFT JOIN " . DB_PREFIX . "zone_to_geo_zone z2gz ON (tr2.geo_zone_id = z2gz.geo_zone_id) LEFT JOIN " . DB_PREFIX . "geo_zone gz ON (tr2.geo_zone_id = gz.geo_zone_id) WHERE tr1.tax_class_id = '" . (int)$tax_class_id . "' AND tr1.based = 'payment' AND tr2cg.customer_group_id = '" . (int)$customer_group_id . "' AND z2gz.country_id = '" . (int)$this->payment_address['country_id'] . "' AND (z2gz.zone_id = '0' OR z2gz.zone_id = '" . (int)$this->payment_address['zone_id'] . "') ORDER BY tr1.priority ASC");
foreach ($tax_query->rows as $result) {
$tax_rates[$result['tax_rate_id']] = array(
'tax_rate_id' => $result['tax_rate_id'],
'name' => $result['name'],
'rate' => $result['rate'],
'type' => $result['type'],
'priority' => $result['priority']
);
}
}
if ($this->store_address) {
$tax_query = $this->db->query("SELECT tr2.tax_rate_id, tr2.name, tr2.rate, tr2.type, tr1.priority FROM " . DB_PREFIX . "tax_rule tr1 LEFT JOIN " . DB_PREFIX . "tax_rate tr2 ON (tr1.tax_rate_id = tr2.tax_rate_id) INNER JOIN " . DB_PREFIX . "tax_rate_to_customer_group tr2cg ON (tr2.tax_rate_id = tr2cg.tax_rate_id) LEFT JOIN " . DB_PREFIX . "zone_to_geo_zone z2gz ON (tr2.geo_zone_id = z2gz.geo_zone_id) LEFT JOIN " . DB_PREFIX . "geo_zone gz ON (tr2.geo_zone_id = gz.geo_zone_id) WHERE tr1.tax_class_id = '" . (int)$tax_class_id . "' AND tr1.based = 'store' AND tr2cg.customer_group_id = '" . (int)$customer_group_id . "' AND z2gz.country_id = '" . (int)$this->store_address['country_id'] . "' AND (z2gz.zone_id = '0' OR z2gz.zone_id = '" . (int)$this->store_address['zone_id'] . "') ORDER BY tr1.priority ASC");
foreach ($tax_query->rows as $result) {
$tax_rates[$result['tax_rate_id']] = array(
'tax_rate_id' => $result['tax_rate_id'],
'name' => $result['name'],
'rate' => $result['rate'],
'type' => $result['type'],
'priority' => $result['priority']
);
}
}
$tax_rate_data = array();
foreach ($tax_rates as $tax_rate) {
if (isset($tax_rate_data[$tax_rate['tax_rate_id']])) {
$amount = $tax_rate_data[$tax_rate['tax_rate_id']]['amount'];
} else {
$amount = 0;
}
if ($tax_rate['type'] == 'F') {
$amount += $tax_rate['rate'];
} elseif ($tax_rate['type'] == 'P') {
$amount += ($value / 100 * $tax_rate['rate']);
}
$tax_rate_data[$tax_rate['tax_rate_id']] = array(
'tax_rate_id' => $tax_rate['tax_rate_id'],
'name' => $tax_rate['name'],
'type' => $tax_rate['type'],
'amount' => $amount
);
}
return $tax_rate_data;
}
public function has($tax_class_id) {
return isset($this->taxes[$tax_class_id]);
}
}
?>
Users browsing this forum: No registered users and 77 guests