Post by payflow » Wed Jan 27, 2010 3:21 am

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.

New member

Posts

Joined
Wed Jan 20, 2010 7:13 am

Post by payflow » Wed Jan 27, 2010 3:55 am

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.

New member

Posts

Joined
Wed Jan 20, 2010 7:13 am

Post by i2Paq » Wed Jan 27, 2010 4:01 am

This sounds like Development.

[topic moved]

Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

Our FREE search: Find your answer FAST!.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by payflow » Wed Jan 27, 2010 5:18 am

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.

New member

Posts

Joined
Wed Jan 20, 2010 7:13 am

Post by Qphoria » Wed Jan 27, 2010 6:25 am

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

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by payflow » Wed Jan 27, 2010 6:58 am

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

New member

Posts

Joined
Wed Jan 20, 2010 7:13 am
Who is online

Users browsing this forum: No registered users and 11 guests