Foxy Forum Status

We're no longer responding to questions via our forum, but we will keep it up for historical reasons. If you can't find the answer you're looking for, please visit our knowledge base or contact us. If there's enough interest in the future, we may bring the forum back.

Odd problem with javascript and smartphones

cowtancowtan Member
in Help edited March 2013
Hi - I have an odd problem turn up when using some javascript in the checkout to update the shipping costs. I have an overload statement -
FC.checkout.overload("updatePrice", "updateMyShippingCost", null);

to recalculate the shipping costs based on the destination country of the shipment and whether or not there is gift wrapping involved. The function that does the recalculation looks like this -
function updateMyShippingCost() {
	var numProducts = fc_json.product_count;
	var basePrice = euro_uk_base;
	var increment = euro_uk_increment;
	var country_code = (jQuery("#use_different_addresses").is(":checked") ? $("#shipping_country").val() : $("#customer_country").val());
	if (country_code != "GB") {
		basePrice = euro_elsewhere_base;
		increment = euro_elsewhere_increment;		
	shippingCost = basePrice + (numProducts - 1) * increment;
	if (jQuery("#gift_wrap").is(":checked")) { shippingCost = shippingCost + euro_gift_wrap; }
	FC.checkout.config.orderFlatRateShipping = shippingCost;

This works perfectly on desktop browsers but doesn't seem to work on either safari or chrome on an iphone. I tried putting in a little alert(country_code) statement and it was always set to GB regardless what was set in either the shipping_country or customer_country fields.

It's hard to see what's going on because it's only on the iphone I've seen this (I haven't tried any other mobile/smartphone devices because I don't have easy access to them). I know it's a slightly obscure problem but has anyone come up against anything similar?


  • fc_adamfc_adam FoxyCart Team

    Could you link us to your store to see this in action? Feel free to whisper it if it's private.
  • fc_adamfc_adam FoxyCart Team

    Testing this on my iPhone - the shipping rate was changing as I changed my country from the UK to Australia, and also checking and unchecking the gift wrapping checkbox.

    Are you still seeing it not working?
  • OK. I've tried testing it a bit more and it seems that when you select a country from the drop-down list it works fine but if you type the whole of the company name then it doesn't. Since it happens in both Safari and Chrome I'm guessing that something in the depths of the system isn't recognising when a value in a text field has been changed.
  • fc_adamfc_adam FoxyCart Team

    Just to clarify, when you say this:
    but if you type the whole of the company name then it doesn't

    Are you referring to the company field, or the country field, and if the latter do you mean that you type out the whole country name and then tap onto the next field, without interacting with the autosuggested results?
  • Sorry Adam. Bit of finger trouble there. I meant country field and yes, exactly, it's when I type out the whole country name and then tap onto the next field (or tap the 'next' button) without interacting with the autosuggested results that it doesn't work.
  • fc_adamfc_adam FoxyCart Team

    Ah yep, I'm seeing that now.

    This comes down to our old autocompleter, which unfortunately we won't be making any changes to at this point. I'd strongly suggest upgrading to 1.1 (1.0 at least) and make use of the new foxycomplete included with that - it will work much nicer in general - and play nice with mobile as well.
  • OK. Thanks Adam
Sign In or Register to comment.