editing regions.inc.twig

saint_malosaint_malo Member
in Help edited October 2016
Hi Foxycart,

I came across some problems this afternoon trying to customise regions.inc.twig so that I can tweak the country field. When I try and include that block in my checkout template the country field doesn't populate and I get many-a-browser-error in my browser console. Infact in some instances, I can't actually browse back up to the top of the page - which generates around 300+ errors in a matter of no time. And all of this before I've even made any customisations!

I'm not trying todo anything too fancy with regions.inc.twig - just editing the markup slightly and adding a few extra class names that connect with my CSS framework.

I've tried adding the follow above the regions.inc.twig code block, but that has no result.
{% set location_type = country %}

Any help appreciated!
Comments
  • fc_romanfc_roman Member, FoxyCart Team
    @saint_malo,

    Sorry to hear about the swarm of console errors and thank you for the link.

    Would you mind describing your goals with regions.inc.twig?
    (If only to confirm that there is no easier way to achieve what you're after.)

    Thank you.
  • saint_malosaint_malo Member
    edited October 2016
    Hi @fc_roman

    I wanted the country field to just be a standard select drop down menu - when I switched the combo box off, there was no default placeholder text in the select menu. I wanted to place a "please select an option..." message in the select field.

    Also, I wanted to add a class of "inputGroup" to "fc-container__grid--country" and a class of "inputItem" to the select menu, to make the country field markup consistent with the fields I have already customised/styled above it.
  • fc_adamfc_adam FoxyCart Team
    @saint_malo,

    Sorry for the pain here - while it's straight-forward to edit the top tier twig includes like checkout.inc.twig - once you get deeper it gets much more complex. We're discussing ways to improve that in the future.

    I just tried out your template on my own test store, and I can see the javascript errors you mention - relating to an error with the Twig template. If I update it to include the {% set location_type = "country" %} line right before your embedded regions.inc.twig, it works just fine. Could you give that another try perhaps?
  • saint_malosaint_malo Member
    edited October 2016
    @fc_adam Thanks adam - that worked.

    Adding inverted commas around country in {% set location_type = country %} did the trick - i was close!

    Further up my template, when i included address.checkout.twig to customise the shipping address, i used:
    {% set address = shipping_address %} with the contents of address.checkout.twig below it.

    That seemed to work - should i add inverted commas around shipping_address too? Is that the correct syntax? Or does it depend on what level you include these blocks in?
  • fc_adamfc_adam FoxyCart Team
    @saint_malo,

    Good question. The shipping address line is correct - the difference is that shipping_address is a variable, so it's a direct reference to that, where as "country" is a string, so needs to be quoted.
Sign In or Register to comment.