• Resolved nbruley

    (@nbruley)


    On this page:
    https://publicacionespescadores.com/realizar-pedido

    I have an onchange event tied to the country dropdown. The following error occurs when selecting the “Estados Unidos” country option only:

    Uncaught Error: Syntax error, unrecognized expression: option[value=]

    I have found that if I change the ID for the option to “USA” instead of “US” the error disappears. There appears to be some javascript conflict or something. But the referenced onchange function is not running– it is erroring out before that.

    Any ideas on what might be causing this? I’m stumped. If not, can you tell me how to change the ID for the country to a different abbreviation, or how to change the ID assigned to the country dropdown on the finalize order page?

    https://wordpress.org/plugins/jigoshop/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter nbruley

    (@nbruley)

    Plugin Author Jigoshop Support – Krzysztof

    (@krzysztofk-1)

    Hi nbruley,

    It looks like this is jigoshop bug. It will be fixed in new release.

    Thread Starter nbruley

    (@nbruley)

    OK thank you. Can you please tell me which file can be adjusted to temporarily give the functionality I need until then?

    Plugin Author Jigoshop Support – Krzysztof

    (@krzysztofk-1)

    In jigoshop/assets/js/countries.js replace line 39 with this code: $('option[value="'+selected+'"]', $state).attr('selected', 'selected');

    Thread Starter nbruley

    (@nbruley)

    That fixes the error. There is only one more problem that didn’t used to be a problem, with the following code:

    $(‘div.payment_method_bank_transfer’).hide();

    Does not hide that particular section on page load, but it does hide it after page load. Is there some coding going on that would affect this?

    I have tried two different ways of coding it and it just doesn’t go away. The bank transfer information should only be shown if the user selects Mexico before getting to the confirm your order page. Otherwise it should not be visible. The rest of the Mexico payment type information is hidden properly, but I can’t get rid of the bank info.

    Plugin Author Jigoshop Support – Krzysztof

    (@krzysztofk-1)

    I think it would be better to hide parent instead of hiding all childs.

    Try this code:

    jQuery(document).ready(function($){
    	function refreshGateways() {
    		switch($('#billing_country').val()){
    			case 'MX':
    				$('#payment_method_bank_transfer').prop('checked',true);
    				$('#payment_method_bank_transfer').parent().slideDown(500);
    				$('#payment_method_paypal').parent().slideDown(500);
    				$('#payment_method_cod').parent().slideUp(500);
    				break;
    			case 'US':
    				$('#payment_method_paypal').prop('checked',true);
    				$('#payment_method_bank_transfer').parent().slideUp(500);
    				$('#payment_method_paypal').parent().slideDown(500);
    				$('#payment_method_cod').parent().slideUp(500);
    				break;
    			default:
    				$('#payment_method_cod').prop('checked',true);
    				$('#payment_method_bank_transfer').parent().slideUp(500);
    				$('#payment_method_paypal').parent().slideUp(500);
    				$('#payment_method_cod').parent().slideDown(500);
    				break;
    		}
    	}
    	refreshGateways();
    	$('#billing_country').change(refreshGateways);
    });

    Thread Starter nbruley

    (@nbruley)

    Thanks! That works well apart from the fact that for whatever reason when the page finishes loading, the selection of the payment method gets lost. I thought maybe it was the slide up/down but that wasn’t it either.

    Plugin Author Jigoshop Support – Krzysztof

    (@krzysztofk-1)

    Maybe you have default gateway selected in jigoshop database.

    Thread Starter nbruley

    (@nbruley)

    I do not see a way to unselect a default gateway. Is there a way to disable that? Previously this worked, or at least in a previous Jigoshop version… I guess it’s not a big deal to make the customer select it though, but it would be nice to do it for them, especially if there is only one option.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Error when selecting country with change event’ is closed to new replies.