Shipping/Billing Fields

sparkwebsparkweb Member, Integration Developer, FoxyShop, Order Desk
in Help edited October 2010
Is there a simple way to make sure that the shipping address always gets filled in? Right now, if the buyer doesn't specify a separate shipping address the shipping fields are left empty. I understand why this is happening, but it's a pain since they are trying to create labels and want to be able to just pull from one field instead of having to write some sort of excel query to pick which one get from.

Any ideas?
Comments
  • brettbrett FoxyCart Team
    edited October 2010
    This has come up before, and we'd discussed changing the behavior a little, but we haven't done so yet.

    You could conceivably add some javascript to fill in the hidden shipping fields with what's in the billing fields before checkout submission I think.

    What FoxyCart version are you on?
  • sparkwebsparkweb Member, Integration Developer, FoxyShop, Order Desk
    edited October 2010
    I'm on v .70.

    I took your advice and wrote this code which seems to work fine. There's probably a more efficient way to do it, but I couldn't figure exactly how to ensure that this gets run right before submit. Anyway, this seems to work fine.
    <script type="text/javascript">
    jQuery(document).ready(function($) {
    	$("#fc_form_checkout input").blur(function() {
    		if (!$("#use_different_addresses").is(":checked")) {
    			var names = ["first_name","last_name","company","address1","address2","city","state_name","postal_code","phone"];
    			for (var i in names) {
    				$("#shipping_"+names[i]).val($("#customer_"+names[i]).val());
    			}
    		}
    	});
    
    });
    </script>
    
  • brettbrett FoxyCart Team
    That's actually fairly elegant, imo. Nice work! I've added it to http://wiki.foxycart.com/docs:advanced:forum
  • sparkwebsparkweb Member, Integration Developer, FoxyShop, Order Desk
    Brett, what I'm hearing from the customer is that this is not working. Does FoxyCart save the shipping information even if the "use different" checkbox is not checked?

    Subdomain is "fashionable"
  • Brett - FYI, I think copying the billing address to the shipping address in these instance is the correct behavior. I'm doing it myself in my datafeed now, but I did need to add specific logic to catch these conditions.
  • lukeluke FoxyCart Team
    Thanks for posting everyone. I agree, it should be included in both the shipping and billing locations. That makes a lot of sense. My only concern with making a change there is that someone might be triggering of these values to determine if there has to be a separate address at all and if it's the same as the billing, that might confuse things in a third party system and create duplicate addresses.

    @sparkweb: I do think there is a check in our system against the "use different" checkbox so just populating the fields won't be enough. As BillDA mentioned, working with the data sent from the XML Datafeed is probably the best way to go (for now). I actually found a ticket we created for this a couple months ago. Thanks for posting.
Sign In or Register to comment.