Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Collecting taxes on store pickup purchases...


c.jordan84

Recommended Posts

Posted

I have a problem I've been working on for the last three days and it's driving me up the wall. I've approached it from several different angles, but no luck thus far. I'm trying to use store pickups along with regular shipping options to present the customer with two choices: when you order, you can come here and pick it up, or we can ship it to you. Seems simple, right?

 

There isn't really a problem with the shipping, although I do need to do a bit of tweaking with the weights and available options. The problem is trying to collect taxes on store pickup purchases. When the customer buys something and selects the pickup option, the software looks at their shipping address that's stored in the database and selects the zone information from there. Now if it was someone from our state that was buying it, there'd be no problem. However, we're on the border between Mississippi and Louisiana and we have a lot of people crossing the state border to buy from our brick-and-mortar business, so we'd want to charge sales tax for anything that was bought online to be picked up at the store.

 

So I've been pouring through the checkout pages and several class and function pages searching for what I'd need to change. The first thing I tried was to eliminate the shipping address by changing the process to a virtual purchase. It eliminated the address, but I still couldn't find a way to add tax to the purchase. After several hours of variable editing and function experimentation, it occurred to me that if I changed the zone ID in the address book database, it would give me enough time to add tax to the purchase and change the zone id back. Still, no dice there either.

 

I haven't given up; I'm drawing multiple flowcharts of functions and variables and how the change from page to page.

 

What I'd love is for someone to tell me I'm stupid and I missed a very important button somewhere that would relieve the problem :) However, if that's not the case, any help offered would be greatly appreciated.

 

site url: http://theothersidepop.com/catalog/

 

 

Edit:

A little bit of info I found: If I'm on the confirmation page and the buyer's, say, from Texas (entry_zone_id: 57) and I go to the database and change the zone_id to 35 and reload the page, the tax shows up... so I figure all I have to do is find where it's making a database query for the zone and edit it to pull 35 when $sendto = false... I think that might work, so I'm going to try that.

Posted

Fixed it!

 

This is how:

 

I've got two separate shipping pages: checkout_shipping.php and checkout_pickup_shipping.php. The second one is a redirect page, but it doesn't really matter, just as long as $shipping is set to FALSE.

 

Now in includes/classes/order.php, I did this:

 

under the cart() function changed:

 

$tax_address_query = tep_db_query("select ab.entry_country_id, ab.entry_zone_id from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) where ab.customers_id = '" . (int)$customer_id . "' and ab.address_book_id = '" . (int)($this->content_type == 'virtual' ? $billto : $sendto) . "'");

 

to:

 

if ($shipping != false)

{

$tax_address_query = tep_db_query("select ab.entry_country_id, ab.entry_zone_id from " . TABLE_ADDRESS_BOOK . " ab left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id) where ab.customers_id = '" . (int)$customer_id . "' and ab.address_book_id = '" . (int)($this->content_type == 'virtual' ? $billto : $sendto) . "'");

$tax_address = tep_db_fetch_array($tax_address_query);

} else

{

$tax_address = array('entry_zone_id' => 35,

'entry_country_id' => 223);

}

 

 

Yes, it's hard-coded, but the principal is still there.

 

I then changed this:

 

$this->delivery = array('firstname' => $shipping_address['entry_firstname'],

'lastname' => $shipping_address['entry_lastname'],

'company' => $shipping_address['entry_company'],

'street_address' => $shipping_address['entry_street_address'],

'suburb' => $shipping_address['entry_suburb'],

'city' => $shipping_address['entry_city'],

'postcode' => $shipping_address['entry_postcode'],

'state' => ((tep_not_null($shipping_address['entry_state'])) ? $shipping_address['entry_state'] : $shipping_address['zone_name']),

'zone_id' => $shipping_address['entry_zone_id'],

'country' => array('id' => $shipping_address['countries_id'], 'title' => $shipping_address['countries_name'], 'iso_code_2' => $shipping_address['countries_iso_code_2'], 'iso_code_3' => $shipping_address['countries_iso_code_3']),

'country_id' => $shipping_address['entry_country_id'],

'format_id' => $shipping_address['address_format_id']);

 

to this:

 

if ($shipping != false)

{

$this->delivery = array('firstname' => $shipping_address['entry_firstname'],

'lastname' => $shipping_address['entry_lastname'],

'company' => $shipping_address['entry_company'],

'street_address' => $shipping_address['entry_street_address'],

'suburb' => $shipping_address['entry_suburb'],

'city' => $shipping_address['entry_city'],

'postcode' => $shipping_address['entry_postcode'],

'state' => ((tep_not_null($shipping_address['entry_state'])) ? $shipping_address['entry_state'] : $shipping_address['zone_name']),

'zone_id' => $shipping_address['entry_zone_id'],

'country' => array('id' => $shipping_address['countries_id'], 'title' => $shipping_address['countries_name'], 'iso_code_2' => $shipping_address['countries_iso_code_2'], 'iso_code_3' => $shipping_address['countries_iso_code_3']),

'country_id' => $shipping_address['entry_country_id'],

'format_id' => $shipping_address['address_format_id']);

} else {

$this->delivery = array('firstname' => 'The Other ',

'lastname' => 'Side',

'street_address' => '109 W Beers St',

'city' => 'Poplarville',

'postcode' => '39470',

'state' => 'Mississippi',

'zone_id' => 35,

'country' => array('id' => $shipping_address['countries_id'], 'title' => $shipping_address['countries_name'], 'iso_code_2' => $shipping_address['countries_iso_code_2'], 'iso_code_3' => $shipping_address['countries_iso_code_3']),

'country_id' => $shipping_address['entry_country_id'],

'format_id' => $shipping_address['address_format_id']);

}

 

Once again, it's a hard-code job, but it works for what I need, for the moment. Unfortunately, I haven't gotten far enough to fix the misreport it causes with confirmation emails, but it'll be fixed by tomorrow afternoon.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...