Author Topic: Add a vmstates element?  (Read 3612 times)

Stephen Roberts

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 142
    • SundaySchool.com
Add a vmstates element?
« on: December 14, 2011, 22:10:44 pm »
How do you guys feel about adding a vmstates element? I copied vmcountries, modified it for states and attached it to this post. Would love to see it in an upcoming revision!

[attachment cleanup by admin]
Sell downloadable (virtual) products in VirtueMart 2 and deliver downloads via local server, Amazon S3, and more! http://www.digitollsoftware.com

jjk

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3505
  • using Matomo instead of Google Analytics
Re: Add a vmstates element?
« Reply #1 on: December 14, 2011, 22:48:52 pm »
Just curious, what do you want to use it for? ...as VM2 already uses states as part of the "Countries" view in the backend.
See screenshot below

[attachment cleanup by admin]
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

Stephen Roberts

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 142
    • SundaySchool.com
Re: Add a vmstates element?
« Reply #2 on: December 14, 2011, 22:50:23 pm »
I need to use it for my shipping plugin configuration. We have certain rules depending on states, so a state element would be an easy and nice way to do it.
Sell downloadable (virtual) products in VirtueMart 2 and deliver downloads via local server, Amazon S3, and more! http://www.digitollsoftware.com

jjk

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3505
  • using Matomo instead of Google Analytics
Re: Add a vmstates element?
« Reply #3 on: December 14, 2011, 23:12:40 pm »
If it's for different tax rules i.e. for all US States, you can set up that in Tax & Calculation Rule Details. You just have to assign one or more states for each different tax rule.
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9918
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Add a vmstates element?
« Reply #4 on: December 14, 2011, 23:14:28 pm »
Did you tried the country state dropdown? Just select two different countries with states and I think you will understand. When you want to show only states of one country, just disable all countries, except one...
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Stephen Roberts

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 142
    • SundaySchool.com
Re: Add a vmstates element?
« Reply #5 on: December 14, 2011, 23:52:17 pm »
Hm, I'm not sure I follow. In my shipping method, I need to be able to say:

Apply to all 51 states of the United States EXCEPT Alaska and Hawaii.

So I'm using the vmstates element to select the states to exclude from the shipping method. Is there a better way already built-in to accomplish this?
Sell downloadable (virtual) products in VirtueMart 2 and deliver downloads via local server, Amazon S3, and more! http://www.digitollsoftware.com

jjk

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3505
  • using Matomo instead of Google Analytics
Re: Add a vmstates element?
« Reply #6 on: December 15, 2011, 10:13:44 am »
Ok, I think your case is a little different. Different taxes for different states is easy to set up in the calculation rules. Your (the postal services) surcharge for shipments to Hawaii and Alaska might be a tricky problem for non-coders. If you use one of the calculation options available in the calculation rule settings, you have a problem displaying this as shipping cost in the cart. If you set up a shipping method, VM2 currently doesn't offer the state selection option, like in the calculation rule settings.

So, perhaps you should submit "add state selection to shipping methods configuration" as a feature request.
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

alatak

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2047
    • alatak.net
Re: Add a vmstates element?
« Reply #7 on: December 15, 2011, 12:48:18 pm »
Hi,

Txs Stephen for your submitting that file.
As mentionned in a previous post, the states are related to the countries.
Some countries do have states , some others not. The file you wrote, cannot be used in an universal way.

May be in your case, you can write a shipment method specific to US, and then use your file as you wrote it.

jjk

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3505
  • using Matomo instead of Google Analytics
Re: Add a vmstates element?
« Reply #8 on: December 15, 2011, 13:19:46 pm »
Just another  (maybe the most simple) idea. You could use "Zip Code Start" and "Zip Code End" in shipping methods configuration to set up special shipping rules for Alaska and Hawaii.
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

Stephen Roberts

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 142
    • SundaySchool.com
Re: Add a vmstates element?
« Reply #9 on: December 15, 2011, 17:31:53 pm »
Quote
As mentionned in a previous post, the states are related to the countries.
Some countries do have states , some others not. The file you wrote, cannot be used in an universal way.

You're correct, some countries don't have states and in that case, you don't need to select anything in the state field. I understand that it's an issue that the state element is not connected to the country element, so the state element shows all states regardless of what country is selected. At the same time, wouldn't it be a good idea to at least offer a state element to developers like me and let us decide how to use it?

Quote
Just another  (maybe the most simple) idea. You could use "Zip Code Start" and "Zip Code End" in shipping methods configuration to set up special shipping rules for Alaska and Hawaii.

A zip range won't work. It may in the example I provided, but in more complex cases, it won't work.

Is there any other option for this? I hate to add my custom element to VM2, but the only other solution I can think of would be a manual solution like typing in the states' code (AK, HI) in a field which isn't ideal at all.
Sell downloadable (virtual) products in VirtueMart 2 and deliver downloads via local server, Amazon S3, and more! http://www.digitollsoftware.com

Stephen Roberts

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 142
    • SundaySchool.com
Re: Add a vmstates element?
« Reply #10 on: December 15, 2011, 17:40:55 pm »
What about a combined country-state element? That way they would be linked together.
Sell downloadable (virtual) products in VirtueMart 2 and deliver downloads via local server, Amazon S3, and more! http://www.digitollsoftware.com

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9918
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Add a vmstates element?
« Reply #11 on: December 15, 2011, 19:03:49 pm »
lol, sorry but you never used the country/state thing, because it IS a combo. I underline again, try that "Just select two different countries with states", okey it maybe not an element, but it is already there.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

jjk

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3505
  • using Matomo instead of Google Analytics
Re: Add a vmstates element?
« Reply #12 on: December 15, 2011, 19:14:57 pm »
oops - Milbo replied while I was typing this...

That's what I meant earlier with
Quote
So, perhaps you should submit "add state selection to shipping methods configuration" as a feature request.
Hope we are talking about the same idea :-)

...in other words, I thought it might make VM2 life easier for folks in the US and CAN if the the option marked red in the image below would be also added to the shipping method configuration.
 :)


[attachment cleanup by admin]
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

Stephen Roberts

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 142
    • SundaySchool.com
Re: Add a vmstates element?
« Reply #13 on: December 15, 2011, 21:13:31 pm »
So if I understand this correctly, VM does have country-state support (which I already knew), but it does not have that support as an element which means that it cannot be used in the configuration of a shipping plugin because the configuration is set up through the plugin XML file.

So what I'm asking for is NOT already a feature correct? If that's the case, just postpone this feature request until after the VM2 final release. I'll make due until then.

By the way, you guys are doing really great work. It's been a pleasure working with VM2 so far!
Sell downloadable (virtual) products in VirtueMart 2 and deliver downloads via local server, Amazon S3, and more! http://www.digitollsoftware.com

alatak

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2047
    • alatak.net
Re: Add a vmstates element?
« Reply #14 on: December 15, 2011, 21:27:34 pm »
Hi,

Quote
So if I understand this correctly, VM does have country-state support (which I already knew), but it does not have that support as an element which means that it cannot be used in the configuration of a shipping plugin because the configuration is set up through the plugin XML file.
Yes exactly. That is the reason.
Afaik, it is not possible to write an element for which the value depends on another value.
May be it is possible, but I never tried.

The predefined types are here:
http://docs.joomla.org/Standard_form_field_types