VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: Stephen Roberts on December 14, 2011, 22:10:44 PM

Title: Add a vmstates element?
Post by: Stephen Roberts 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]
Title: Re: Add a vmstates element?
Post by: jjk 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]
Title: Re: Add a vmstates element?
Post by: Stephen Roberts 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.
Title: Re: Add a vmstates element?
Post by: jjk 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.
Title: Re: Add a vmstates element?
Post by: Milbo 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...
Title: Re: Add a vmstates element?
Post by: Stephen Roberts 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?
Title: Re: Add a vmstates element?
Post by: jjk 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.
Title: Re: Add a vmstates element?
Post by: alatak 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.
Title: Re: Add a vmstates element?
Post by: jjk 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.
Title: Re: Add a vmstates element?
Post by: Stephen Roberts on December 15, 2011, 17:31:53 PM
QuoteAs 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?

QuoteJust 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.
Title: Re: Add a vmstates element?
Post by: Stephen Roberts on December 15, 2011, 17:40:55 PM
What about a combined country-state element? That way they would be linked together.
Title: Re: Add a vmstates element?
Post by: Milbo 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.
Title: Re: Add a vmstates element?
Post by: jjk on December 15, 2011, 19:14:57 PM
oops - Milbo replied while I was typing this...

That's what I meant earlier with
QuoteSo, 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]
Title: Re: Add a vmstates element?
Post by: Stephen Roberts 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!
Title: Re: Add a vmstates element?
Post by: alatak on December 15, 2011, 21:27:34 PM
Hi,

QuoteSo 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


Title: Re: Add a vmstates element?
Post by: Stephen Roberts on December 15, 2011, 21:37:56 PM
Yeah, I've never heard of an element like that. I might try some code and see if I could get something to work. In the meantime I'll stick to my vmstates element. Thanks for the discussion!