News:

Support the VirtueMart project and become a member

Main Menu

Is there a good fix for the "states dropdown" problem?

Started by JDmpdx, May 06, 2015, 20:57:06 PM

Previous topic - Next topic

JDmpdx

Hello- 

I'm on VM 3.0.8 / J! 3.4.1, but I've seen threads about this issue dating back to VM 1.x, and haven't seen any solid fixes for it. Hopefully, I'm just missing the answer, but... Ok, when someone goes to checkout and selects the country (in my case the United States), the States dropdown does not work. It seems to be the one field on the cart page that just keeps giving problems, but I can't seem to make it work properly, although I've tried tons of various combinations of settings for that field and for the various ajax / jquery / JS settings in VM itself.  I've seen a few workarounds posted, such as hacking VM to replace that w/ just a text field. But, I'm wondering if there's a better fix out there.   Also running Gantry (a RT template), in case that helps... not sure if that's a possible conflict-cause here?

Site is: https://www.mineratminerals.com

-Jim

jenkinhill

Before doing anything elae you should rule out the template as an issue by switching to Protostar to see if the dropdown works there.  If not then it could be a third party plugin such as a gallery.

Have you tried a debugger on the page?  http://forum.virtuemart.net/index.php?topic=119638.0
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

JDmpdx

Oh yes, will try that!  Will let you know and report any success here!  There IS one rather Javascripty-intense (to coin a phrase) module on that page that I didn't try disabling yet.

GJC Web Design

I don't see any of the required JS being even loaded on https://www.mineratminerals.com/for-sale/user/editaddresscartBT

chosen.js, vmsite.js etc

plus a 500 server error for some com_jrealtimeanalytics  thing

r u sure this template is VM 3 compatible?  AS Jenks says - try with Protosar first

then if ok rename the template  html/com_virtuemart folder
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

JDmpdx

Cool, thanks!  Yeah, I tried Protostar & it still didn't work. But, when you mentioned disabling the overrides, that did the trick. I think it was some code from a prior VM override in there... disabled that & the dropdown kicked back in.  (Still have some of those unrelated junky errors that you also pointed out, thanks. But, yeah, I think maybe some old override code was bonking the system here!) MArked the subject solved. :-)

ingxiong

Hi,
I am having the same problem at http://staging.superageless.com/
as you can see, the site is still using protostar
I only installed Virtuemart, VM Affiliate, that's it
Will appreciate some help or guide on what to do

thx

irwan

GJC Web Design

your loading at least 2 jquery libraries -- add to cart isn't even working

one is coming from your menu
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

jenkinhill

As stated, you have a problem with your menu module loading a version of jQuery which is incompatible with VM2.x
<script src="http://staging.superageless.com/modules/mod_bm_cool_menu/assets/js/jquery-1.11.1.min.js" type="text/javascript"></script>

http://forum.virtuemart.net/index.php?topic=119638.0
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

ingxiong

Thank you very much for your help, somehow it skipped my mind that modules can also interferes with component. It was BM Cool menu and once I disabled it, it works.

Much obliged,

Irwan

trevorbicewebdesign

I am encountering a similar issue on a 3.0.10 site. I have tried a lot of things, including using a jQuery compilation extension such as Jquery-Easy. Though this does seem to be a very helpful extension, it doesn't seem to have solved the problem with my virtuemart_state_id drop-down not being populated properly.

I did a bit of tracing, and am pretty sure there is some kind of JS error along the way I am having a hard time spotting where its breaking down. It seems the system is definitely returning the properly formatted json options, but they are not getting correctly populated into the dropdown?

Anyone have any ideas? I'm gonna see if  I can spot where its breaking down in the meantime...
Never underestimate the power of stupid people in large groups.
http://webdesign.trevorbice.com/

trevorbicewebdesign

So after a few more minutes of hunting, I think I figured out where my problem is coming from. The site I am currently running is in a subfolder, jupgrade, as I am migrating this site originally from a Joomla 1.5x and Virtuemart 1.18x site. It looks like the ajax call in the 'components/com_virtuemart/assets/js/vmsite.js' file is using a relative path. After SEF urls are enabled, this relative path is going relative to the server and thus is breaking down and not returning any values.

I am not really sure of the solution to make this compatible with all different site configurations using only java-script. It would be necessary for the system to know that it is operating in a subfolder, and adjust the AJAX calls accordingly. Maybe someone with a better understanding of Virtuemart 3's inner workings might have an idea how to pull this off. I usually dev sites on subdomains, but I'm sure there are plenty of users out there in subfolders that are probably having this same issue.
Never underestimate the power of stupid people in large groups.
http://webdesign.trevorbice.com/

Milbo

Thank you trevor for writing the problem to me.

The solution is to use in vmsite.js around line 49-50
            jQuery.getJSON(window.vmSiteurl + 'index.php?option=com_virtuemart&view=state&format=json&virtuemart_country_id=' + byAjax,

and we have to add the vmSiteurl to the calling js, so that it is known. I am going to change this later so that we have always a Virtuemart.vmSiteurl, but now for testing.
Open the vmsjapi.php in /administrator/components/com_virtuemart/helpers. and replace the function JcountryStateList with


static function JcountryStateList($stateIds, $prefix='') {
static $JcountryStateList = array();
if (isset($JcountryStateList[$prefix]) or !VmConfig::get ('jsite', TRUE)) {
return;
}
VmJsApi::jSite();
self::addJScript('vm.countryState'.$prefix,'
//<![CDATA[
vmSiteurl = "'.JURI::root().'";'."\n".'
jQuery( function($) {
$("#'.$prefix.'virtuemart_country_id").vm2front("list",{dest : "#'.$prefix.'virtuemart_state_id",ids : "'.$stateIds.'",prefiks : "'.$prefix.'"});
});
//]]>
');
$JcountryStateList[$prefix] = TRUE;
return;
}
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/