Page 1 of 1

Handling (by GeoZone) supported?

Posted: Wed Jan 27, 2010 3:21 am
by payflow
Looking at the source code, it looks like the shipping address determines tax. However, the rules are not that simple (I wish they were). Our current store (which is awful, hence the switch to OpenCart) uses the following rule for determining if tax applies:

if ($billing_state != "AZ" && $shipping_state != "AZ") $tax = 0;
else $tax = ...;

If either the Billing or Shipping address is in the state, we can charge sales tax on taxable items because we handle the items. I suppose this is why it is called Shipping and "Handling". I don't make these rules up, I just make sure they get applied correctly.

I think the following modification will work, but I'd like someone to review who knows OpenCart better than me:

Code: Select all

			if ($this->cart->hasShipping()) {
				$this->tax->setZone($this->request->post['country_id'], $this->request->post['zone_id']);
			}
Becomes:

Code: Select all

			if ($this->cart->hasShipping()) {
				if ($this->request->post['country_id'] != $this->config->get('config_country_id') || $this->request->post['zone_id'] != $this->config->get('config_zone_id')) {
					$this->tax->setZone($this->request->post['country_id'], $this->request->post['zone_id']);
				} else {
					$this->tax->setZone($this->config->get('config_country_id'), $this->config->get('config_zone_id'));
				}
			}
For guest checkout. I figure something similar will need to show up in account-based purchases.

Re: Handling (by GeoZone) supported?

Posted: Wed Jan 27, 2010 3:55 am
by payflow
Wait. That code doesn't do anything different. Probably because I removed the modifications I'm making to guest_step_1 to offer both Billing and Shipping addresses.

Code: Select all

			if ($this->cart->hasShipping()) {
				if (($this->request->post['billing_country_id'] != $this->config->get('config_country_id') || $this->request->post['billing_zone_id'] != $this->config->get('config_zone_id')) && ($this->request->post['shipping_country_id'] != $this->config->get('config_country_id') || $this->request->post['shipping_zone_id'] != $this->config->get('config_zone_id'))) {
					$this->tax->setZone($this->request->post['shipping_country_id'], $this->request->post['shipping_zone_id']);
				} else {
					$this->tax->setZone($this->config->get('config_country_id'), $this->config->get('config_zone_id'));
				}
			}
Should work better.

Re: Handling (by GeoZone) supported?

Posted: Wed Jan 27, 2010 4:01 am
by i2Paq
This sounds like Development.

[topic moved]

Re: Handling (by GeoZone) supported?

Posted: Wed Jan 27, 2010 5:18 am
by payflow
Oh. Sorry. I put it in Support initially because I was hoping there was already a way to do what I want that was already built into the system and someone would point me in the right direction.

Re: Handling (by GeoZone) supported?

Posted: Wed Jan 27, 2010 6:25 am
by Qphoria
I'm not sure about the logic tho. if billing state = AZ and shipping state = AZ then no tax? Thats actually the only time you should be charging tax under normal us laws

Re: Handling (by GeoZone) supported?

Posted: Wed Jan 27, 2010 6:58 am
by payflow
I probably got the logic wrong. If BOTH addresses are not in AZ, then no tax. Otherwise, tax. I think this works better:

Code: Select all

			if ($this->cart->hasShipping()) {
				if (($this->request->post['payment_country_id'] == $this->config->get('config_country_id') && $this->request->post['payment_zone_id'] == $this->config->get('config_zone_id')) || ($this->request->post['shipping_country_id'] == $this->config->get('config_country_id') && $this->request->post['shipping_zone_id'] == $this->config->get('config_zone_id'))) {
					$this->tax->setZone($this->config->get('config_country_id'), $this->config->get('config_zone_id'));
				} else {
					$this->tax->setZone($this->request->post['shipping_country_id'], $this->request->post['shipping_zone_id']);
				}
			}
Logic (global zone US-AZ):

Payment: US-AZ, Shipping: US-TX... Zone: US-AZ
Payment: US-TX, Shipping: US-AZ... Zone: US-AZ
Payment: US-AZ, Shipping: US-AZ... Zone: US-AZ
Payment: US-TX, Shipping: US-TX... Zone: US-TX