The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

How do I prevent the use a different billing address from messing everything up?

I am making a lot of changes to the checkout page. I have been VERY careful in my changes. Making them a bit at a time. Testing and testing and then making more changes. Backing everything up as I go so that I can backout of any changes.

The checkout page is finally beginning to look somewhat the way I have in mind to make it (though it still needs a fair bit of work) but...when I click the checkbox to use a different address for billing purposes, well...a number of my changes are undone.

I would like to prevent that.

While I could chase things down in the code myself that's very time consuming and I am hoping that someone can do me the favor of pointing me to the relevant section of code where things might need to be changed?

What happens is that Javascript that I have at the end of the checkout template file automagically cached is overridden to put the placeholders all back in again.

And the billing fields are not appearing the way the shipping fields are.

Any advice on how to get around this would be appreciated.


  • I think I figured out what is happening.

    What is happening is that I inserted the code (modified by me) into the checkout template directly but left in place the line where it is called with a value for the address variable of "billing_address".

    {% include "" with {'address': billing_address} %}

    This results in my modified code being called (and displayed) in the shipping address section but the unmodified code (contained in the default being called when the billing address is requested through the code.

    If you see this differently please let me now otherwise I will take it from here and do not need any more input on this thread.



  • Hmm...well...that is working pretty much except some new problems are surfacing that I would appreciate input on.

    If you go to a fresh checkout page from my test page (in whisper on this thread) you will notice that the country field "drop down" appears with the United States preselected in what appears like any other field (no problem in that regard - I will be working to change it's appearance).

    But if you do nothing else on the checkout page but click the check box that says "Use a different address for billing purposes." and then look at the subsequent fields that appear you will notice that the country "drop down" no longer looks like a field but rather like a standard HTML drop down.

    The look of the country drop down is not what I am after pointing out (as I will fix it to look the way I like it later) but rather the inconsistent look of that drop down between when it is found in the shipping fields vs when it is found among the billing fields.

    I didn't do a thing to style this drop down yet so I don't think this is due to a change I made.

    Can someone confirm that this is a FoxyCart thing and if so...can someone give me some idea as to how to make the country drop down look consistent between when it appears inside shipping vs inside billing fields?

    Under a default FoxyCart test store that does NOT include the responsive styles the option to use a different billing address does not appear to show up (I double checked all relevant settings between a test store using my changes where it does show up and a default test store where it doesn't and could not find any setting that would make it appear under a default setup and not).


    Go to the link I provided in the whisper. Select any qty desired and then go through the cart to the checkout.

    Now before doing anything else on the checkout...check the "Use a different address for billing purposes." Now do the following.

    1. As a customer you have changed your mind and want to fill in the zipcode first (I know...very unusual but still). So go back up to the shipping fields and enter "32901" into the zip code field (the United States is the default country selected).

    The Zip and Country fields are repeated FOUR times down the page in both the shipping and billing address sections.

    Can someone confirm that this is a FoxyCart checkout page problem or otherwise and if it is...what I can do to prevent that from happening? I am not so much concerned about this rare case scenario but rather as to what this might say about the underlying code that allows this to happen in terms of it's robustness and stability if indeed this is a FoxyCart problem and not something that has resulted from anything I have done.

    I would have checked this out myself on a test store using default templates but for the life of me I can't figure out how to make the checkbox offering a different billing address show up using the default templates. Last time I dealt with this it involved making a change to the template twig code but new modified store is having it show up just fine as a checkmarked option.


  • Here is the change I made to the template code...

    Overall I inserted a modified into the checkout template where it was previously called and where there was an "with" something or other setting the address field to shipping_address. I then created a block around that modified code. Like so...

    {% block customer_shipping %}
    {# per Carlos: inserted modified here. Original code in foxycart-templates/ #}
    {# BEGIN modified insertion vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv #}

    {% set address = shipping_address %}

    {% block carlos_customer_shipping %}

    <fieldset class="fc-address-entry">

    {% endblock carlos_customer_shipping %}

    {# END modified insertion ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #}

    I then changed the twig code inside the customer_billing block, again in the checkout template (where it previously called like so...

    {% block customer_billing %}
    {% if use_alternate_shipping_address or not shipping_address.has_shippable_products %}

    {# per Carlos: changed the following line to call my customized code defined as
    block: carlos_customer_shipping above #}
    {% set address = billing_address %}
    {{ block('carlos_customer_shipping') }}

    {% endif %}
    {% endblock customer_billing %}

    That is all I did before I noticed and found the checkout form duplicating the Zip and country fields four times down each address section as described above.

    My intention in doing the above was to bypass entirely the code and use my modified version of it instead (which is all contained in the carlos_customer_shipping block inside the checkout template).

  • I finally figured out how to make the Use a different billing address show up in my default template test store and was able to test the above repeating of the zip / country fields.

    I can confirm that this is a result of changes I have made to the default templates as indicated above and NOT to something in the way FoxyCart works out of the box (so to speak).

    Does anyone know why the changes I described above would be causing this to happen?

    Where I defined the code inside (which I copied directly into the checkout template) as a block and then called that block using the {{block('name_of_block')}} syntax?

    What I changed should work based on my understanding of the twig you all use as far as defining a block and calling it from another section of template code.

    I will make this change inside the default template at my default test store and test again but if anyone has any clues about this I would appreciate hearing them.



  • fc_adamfc_adam FoxyCart Team

    The issue appears to be related to my earlier suggestion to define the block in one area and then output that block in another for your custom address template code. Unfortunately there looks to be an issue related to that that is causing the set call before the billing address inclusion to fail. You'll notice that when displayed on the page, both the billing and the shipping blocks are for the shipping address. This is causing the double-ups as a single render of the shipping address fields is occurring twice.

    I'm going to discuss this with the team - as the approach should work, but appears there may be an issue with the Twig.js implementation we're utilising. For now, you'll need to include your custom code in both places rather than defining a block.
  • Thanks for clarifying that Adam.

    I understand. I think what I will do is ask my client if they have ever needed a different address for billing purposes from any client in the past many years that they have been in business. If they haven't...well...that will greatly simplify things in that I will simply blow the whole checkmark to use a different address for billing thing out of the code! :).

    Given all the template file code that I am including directly into the checkout template...I am concerned that is becoming WAY too big - code wise. It's above 110,000 bytes at this point and seems to be slowing things down a bit.

    So I am completely deleting sections in the templates that we don't need at all.

    Maybe the billing section can be one of those :).

    Thanks again for your valuable input Adam!

Sign In or Register to comment.