VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: florihana on February 19, 2018, 12:36:49 PM

Title: Is possible make state input not shown if country has no state ?
Post by: florihana on February 19, 2018, 12:36:49 PM
Virtuemart: 3.0.8
JOOMLA: 3.6

Hi experts,

I'm not sure if anyone had ask this question before or not, but I wonder if it is possible to make state input hide if the country has no state?

So far if the country has no state, then the user only see the state input has this value: -----selection-----

But this will make user confused

see picture below

I had tried out some method with jquery but not working at all

the render state/ country functions are located here:
components/com_virtuemart/helpers/shopfunctionsf.php


BUT it also related to getCountries function (administrator/component/com_virtuemart/model/country.php

I just wondering if there's anyone had ask this kind of question and try to find solution as well?

thank you

Title: Re: Is possible make state input not shown if country has no state ?
Post by: Studio 42 on February 19, 2018, 13:47:25 PM
Does you really need the state ? You can unpublish the state field
Title: Re: Is possible make state input not shown if country has no state ?
Post by: florihana on February 19, 2018, 14:01:16 PM
Yes, in certain country it has to choose state for shipment address
Title: Re: Is possible make state input not shown if country has no state ?
Post by: Studio 42 on February 19, 2018, 14:11:29 PM
A solution is to hide/show state on change countries checking the ID with jquery else you need to hack the Virtuemart core files.
You need to trigger same function on dom ready.
Title: Re: Is possible make state input not shown if country has no state ?
Post by: florihana on February 19, 2018, 15:39:40 PM
This is if countries has not a lot then you could do an dom event binding, but there's lot countries has states so I think the most best solution is doing with core virtuemart function

But it's seems complicated cause it related to lots class
Title: Re: Is possible make state input not shown if country has no state ?
Post by: Studio 42 on February 19, 2018, 16:18:10 PM
You can then check the returned content with javascript and count the options with javascript, you dont need to modify the PHP.