News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

[SOLVED] vmsite.js - state dropdown ignores published status of a state

Started by mb000000, May 24, 2013, 13:54:47 PM

Previous topic - Next topic

mb000000

VM 2.0.20b & J1.5 (yes, really)

I was alerted (indirectly) by a customer to odd behaviour in address handling in VM.  After investigation, it turns out that unpublished states are still included in the address dropdowns.  It seems to me that the issue is in assets/js/vmsite.js which populates the state dropdown after a country dropdown change.  I am still confused by the getJSON call in there which I would have expected to GET from administrator/components/com_virtuemart/views/view.json.php (but doesn't, it GETs from components/com_virtuemart/controllers/state.php) - however, that's my ignorance about Joomla! request handlng.  After experimenting, I see that vmsite.js has access to the State table's "published" field, so I have implemented the following local change to vmsite.js:
FROM -
if (value) group +='<option value="'+ value.virtuemart_state_id +'">'+ value.state_name +'</option>';
TO -
if (value) {
if (value.published == 1) group +='<option value="'+ value.virtuemart_state_id +'">'+ value.state_name +'</option>';
}


If someone can direct me to Joomla docs on explaining why the GET URI index.php?option=com_virtuemart&view=state&format=json&virtuemart_country_id=  ends up at controllers/state.php, that would be handy - thanks

Mark
[Edit - removed debug code from FROM extract - oops!]

Milbo

ah thanks, we exit in the controller if we dont need any overwrite, so long the theory,
why calling a view and a view.html.php? Only to have it overridable, see new version the add to cart pop up. But thanks for this hint, the error was in the getStates function, I added the parameter to get only published ones.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/