Post by straightlight » Fri Dec 16, 2011 12:19 am

The instructions above were for line 17 and 31. Line 23 was not mentioned in the process.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by clapiana » Fri Dec 30, 2011 2:34 am

this issue has been a headache for me, too. tried 3 fresh installs of 1513 with new dbs but no dice. i was using the same zip file which i downloaded for each install. i did end up fixing it by replacing tax.php in system/library with another copy from another 1513 install. maybe it was corrupted during upload but that sounds weak. i looked at both copies of tax.php using winmerg and they came back identical.

New member

Posts

Joined
Thu Sep 01, 2011 6:22 pm

Post by straightlight » Fri Dec 30, 2011 2:36 am

Did you uploaded the file in ASCII mode from FTP / File Manager ? May be that was the problem. ;)

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by takahashi1973 » Wed Jan 18, 2012 10:36 pm

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);
is the wrong replacement code. It returns a different error.

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));
in the original code there was ); instead of )); at the end.
Last edited by qahar on Wed Jan 18, 2012 10:44 pm, edited 1 time in total.
Reason: wrap the code

Active Member

Posts

Joined
Thu Oct 13, 2011 11:41 pm

Post by haydent » Mon Jan 23, 2012 2:59 pm

i tried deleting address's and such with now luck. im mucking around modifying a mod, so im not suprised to find some errors i have to debug.

from my searching so far it seems to be related to left over incomplete data in $this->session->data['guest']

User avatar
Active Member

Posts

Joined
Wed Nov 09, 2011 9:50 am
Location - Sydney, Australia

Post by marvmen21 » Sat Jan 28, 2012 5:08 am

Any solution for this so far?

You want to thank me for my time! :) Click here to donate


Active Member

Posts

Joined
Tue Nov 09, 2010 4:54 am

Post by haydent » Sat Jan 28, 2012 6:51 am

well i made a quick hack as i narrowed down at what actions where causing the incomplete guest data to be written when it wasnt actually needed, and at that point i just put in a unset($this->session->data['guest'])

User avatar
Active Member

Posts

Joined
Wed Nov 09, 2011 9:50 am
Location - Sydney, Australia

Post by clapiana » Wed Feb 01, 2012 4:59 am

fyi

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.

New member

Posts

Joined
Thu Sep 01, 2011 6:22 pm

Post by straightlight » Wed Feb 01, 2012 5:02 am

Since the customer values was imported from one version to another, would it be possible to know with which tool exactly you did made those imports ?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by milky » Wed Feb 01, 2012 10:04 am

I experienced this problem a few minutes ago and searched for the error, landed here. Anyway I was configuring analytics and was trying to set a goal. Needed to set registration as a goal so I deleted my test account, then navigated in store and the error was displayed.

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.

New member

Posts

Joined
Sat Jan 21, 2012 2:04 am

Post by straightlight » Wed Feb 01, 2012 11:32 am

I did wondered myself the consequences it would bring regarding the differences between the admin and customers table so to match the identical emails. While merchants may have no idea it may create an unexpected impact which may be encountered from the orders, eCommerce software are usually developed to avoid using any identical email addresses despite if it comes from the admin or customers table. Both results should remain unique on anyhow.

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()) {
add above both:

Code: Select all

$this->load->model('user/user');
Then, find:

Code: Select all

if ((utf8_strlen($this->request->post['telephone']) < 3) || (utf8_strlen($this->request->post['telephone']) > 32)) {
add above:

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');
	}
}
In admin/language/english/sale/customer.php file,

find:

Code: Select all

$_['error_exists']
add next line:

Code: Select all

$_['error_admin_exists'] = 'Warning: Admin E-Mail Address is already registered!';
Note: Indicating there's an admin email that already exists should only be shown in the admin, not on the store-front.

In admin/controller/user/user.php file,

find twice:

Code: Select all

if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
add above both:

Code: Select all

$this->load->model('sale/customer');
find:

Code: Select all

if ($this->request->post['password'] || (!isset($this->request->get['user_id']))) {
add above:

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');
                }
Then, find:

Code: Select all

$this->data['error_lastname'] = '';
		}
add after:

Code: Select all

if (isset($this->error['email'])) {
	$this->data['error_email'] = $this->error['email'];
} else {
	$this->data['error_email'] = '';
}
Then, in admin/language/english/user/user.php file,

find:

Code: Select all

$_['error_lastname']
add next line:

Code: Select all

$_['error_email'] = 'Email address already exists!';
Then, in catalog/controller/account/register.php file,

find:

Code: Select all

if ($this->model_account_customer->getTotalCustomersByEmail($this->request->post['email'])) {
      		$this->error['warning'] = $this->language->get('error_exists');
    	}
replace with:

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');
}
In catalog/model/account/customer.php file,

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'];
	}
add after:

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'];
}
In catalog/controller/checkout/register.php file,

find:

Code: Select all

if ($this->model_account_customer->getTotalCustomersByEmail($this->request->post['email'])) {
					$json['error']['warning'] = $this->language->get('error_exists');
				}
replace with:

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');
}
This should increase duplicated protection regarding email addresses either for admin or customers from now on.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by gordian » Tue Feb 14, 2012 7:54 am

I had this same error. I had not made any changes. I cleared my cookies and the error disappeared!

Newbie

Posts

Joined
Thu Jan 26, 2012 10:46 am

Post by nadroj » Thu Feb 16, 2012 8:03 am

I am new at this and I have got an error that I cannot figure out. This afternoon I was testing my site and when I was done, i went into the customer and deleted the customer. Now, when I go to the site, I get the following error message: Notice: Undefined index: country_id in /usr/home/jjeansan/public_html/store/system/library/tax.php on line 17Notice: Undefined index: zone_id in /usr/home/jjeansan/public_html/store/system/library/tax.php on line 17Notice: Undefined index: country_id in /usr/home/jjeansan/public_html/store/system/library/tax.php on line 31Notice: Undefined index: zone_id in /usr/home/jjeansan/public_html/store/system/library/tax.php on line

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!

Newbie

Posts

Joined
Sun Feb 05, 2012 11:12 am

Post by straightlight » Fri Feb 24, 2012 10:21 pm

The simple fix is to

replace all instances of:

Code: Select all

$this->setShippingAddress($address_query->row['country_id'], $address_query->row['zone_id']);
with:

Code: Select all

if ($address_query->num_rows) {
    $this->setShippingAddress($address_query->row['country_id'], $address_query->row['zone_id']);
}
This should correct the problem.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Bastiaan » Thu Jan 31, 2013 9:42 pm

I have tried all the above soloutions, nothing worked.

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!

Newbie

Posts

Joined
Wed Jan 30, 2013 6:38 pm

Post by Qphoria » Mon Feb 04, 2013 11:47 pm

Did you alter your registration pages at all?

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Cleo » Sat May 04, 2013 2:43 pm

I got this error too once in a while:

Code: Select all

PHP Notice:  Undefined index:  zone_id in /home/XXXXXXXX/public_html/catalog/controller/account/register.php on line 423
So I checked my catalog/congroller/account/register.php and line 423 and 424 is:

Code: Select all

    	if ($this->request->post['zone_id'] == '') {
      		$this->error['zone'] = $this->language->get('error_zone');
So I compared my register.php file with the one from v1.5.4 and there is a difference between the two:

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')) {
OpenCart v.1.5.4

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')) {
So now I am wondering if I should keep the register.php file that I have or should I replace it with the one from the v.1.5.4 since it look like I still have the one from version 1.5.3.1 because I compared it with the one from 1.5.3.1 and they are identical?

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)


User avatar
Active Member

Posts

Joined
Wed Mar 09, 2011 5:19 am

Post by straightlight » Sat May 04, 2013 10:24 pm

Code: Select all

if ($this->request->post['zone_id'] == '') {
for:

Code: Select all

if (empty($this->request->post['zone_id'])) {
Then,

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')) {
for:

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


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by Cleo » Sun May 05, 2013 7:43 pm

Thank you very much for the help straightlight!

I will make the change!

Regards
Cleo

Opencart v1.5.4.1 fr/en
Theme: Custom
vqmod-2.6.0
PHP: 7.3 (ea-php73)


User avatar
Active Member

Posts

Joined
Wed Mar 09, 2011 5:19 am

Post by josee225 » Sat Nov 23, 2013 4:28 am

Hi,

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]);
  	}
}
?>

New member

Posts

Joined
Tue Dec 27, 2011 10:42 pm
Who is online

Users browsing this forum: Baidu [Spider] and 25 guests