drhenner / ror_ecommerce

Ruby on Rails Ecommerce platform, perfect for your small business solution.
www.ror-e.com
MIT License
1.21k stars 409 forks source link

Trying to decide whether to require_state_in_address #135

Closed jjthames closed 10 years ago

jjthames commented 10 years ago

I'm going back and forth on this and was hoping you could help. Ideally I would like to let people sign up and enter addresses in countries that don't use states/provinces (e.g. Luxembourg). However, it looks like states are used for some fairly important things:

For instance, in the address model I found:

  # hash of all the address attributes to be passed to a creditcard processor
  #
  # @param none
  # @ return [Hash] address attributes for a creditcard processor
  def cc_params
    { :name     => name,
      :address1 => address1,
      :address2 => address2,
      :city     => city,
      :state    => state.abbreviation,
      :country  => state.country_id == Country::USA_ID ? 'US' : 'CAN',
      :zip      => zip_code#,
      #:phone    => phone
    }
  end

I could rewrite the above to pull the country from Address#country, but then I would be left without a state. Is that going to make AuthNet reject transactions?

Also, charging in-state sales tax (obviously) requires knowing what US state you're shipping to.

ShippingZones could only be set up at the national level.

I took a look at Tonx (one of your example sites) and it looks like they have "fake" states set up for New Zealand. I only say they are "fake" because from what I can tell, New Zealand addresses only use street address+city+postal code.

So to sum up my questions:

  1. Do you know if it will break anything to remove the state requirement?
  2. Have you ever done a hybrid approach where the state is optional, or where the state is required only in certain countries?
drhenner commented 10 years ago

Quick answr (I'm at work but I'll add more later)

1) Tonx switched and started using another solution. They were actually the first users of ror_ecommerce. 2) AuthNet should not reject transactions without a state. (I could be wrong but I'm pretty sure) 3) I have removed the state requirement before but I think a couple adjustments need to be made... I'll look more at this later 4) Have you ever done a hybrid approach where the state is optional, or where the state is required only in certain countries? YES 5) charging in-state sales tax might need to change in a big way depending on how the laws are changing. If congress has it's way you need to look at state / county & city taxes. Yep that is crazy and requires and external API call. This is just an FYI. Luckily that is not so important for smaller shops because the laws are more relaxed for those shops. Larger shops are allowed a one year grace period. This is something most e-commerce solutions need to re-implement.

If I have time I'll try to make a solution that you can use and works for the greater good of everyone. I'll only be able to focus on this during the weekend though.

drhenner commented 10 years ago

I actually just fixed a bug for sites that just require Country for shipping zones. Basically if the state is selected & the state has a shipping zone then that shipping zone is used, otherwise the countries shipping zone is used.

I also edited the admin countries so you can select the shipping zone. Currently to edit the shipping zones for the states you need to change db/seed/state.yml or edit the db directly

This was done on purpose because editing is very bad if there are existing orders using the shipping zone. Shipping charges could change if you make an edit.