We need an extra filed at costumer address to integrate with zapier

Hi, we are integrating foxy with zapier, one of the integrations (Boleto simples) demands the costumers neighborhood.

How can we create this extra field at costumers address?

Thank you

Romero Lins
Comments
  • fc_marijafc_marija FoxyCart Team
    Hi @leaodonorte -

    You can create this field by adding some html to your checkout template:

    • In the "checkout template" textarea, look for {% endembed %} near the bottom, and paste this html right above that line:

    {% block customer_billing %}
    {{ parent() }}
    <div class="fc-form-group fc-custom-field__neighborhood-container">
    <div class="col-sm-3"></div>
    <div class="col-sm-8 col-xs-12">
    <input type="text" placeholder="Neighborhood" name="neighborhood" id="neighborhood" aria-required="false" autocomplete="off" class="fc-form-control" value="{{ neighborhood }}" />
    </div>
    </div>
    {% endblock %}


    • Save the checkout template

    Then, to reposition the field to a better location, you'll put a script on your custom footer in the configuration:
    • Head to the "configuration" section
    • Paste the contents below at the bottom of the "custom footer" textarea of the "Add custom header and footer code to your templates" option:

    {% if context == "checkout" %}
    <script>
    FC.client.on("ready.done", reposition);
    FC.client.on("render.done", reposition);

    function reposition() {
    $(".fc-form-group.fc-custom-field__neighborhood-container").insertAfter(".fc-checkout__section--customer-billing-address .fc-address-entry__address-container");
    }
    </script>
    {% endif %}

    • Save the configuration.

    Note that this will add the "Neighborhood" field to the receipt under the "Additional Fields" heading. If you want this to appear differently, let us know how you'd like it to appear.

    You'll then access that value using {{ custom_fields.neighborhood.value }}

    Hope that helps.
  • Thank you!
  • Hi @fc_marija, thanks i think we will need to move from additional fields, as this is part of address, also a name change is needed, please check the changes needed from red to blue on image.

    image


    Can you help me?

    Thanks!


  • fc_marijafc_marija FoxyCart Team
    edited March 11
    Hello @leaodonorte -

    I want to run this by someone else here as to the best way to do this. It looks like you're wanting to move it on the email receipt – do you want to move it on the web receipt as well? You can see what the web receipt looks like by clicking (view) under the transaction ID in the transactions history of the Foxy admin.
  • fc_marijafc_marija FoxyCart Team
    Hello again @leaodonorte -

    I have a snippet for you to add to your checkout template to show the field in the desired place on the email. To apply it:
    1. Go to the email receipt settings in the Foxy admin (https://admin.foxycart.com/admin.php?ThisAction=EditTemplate&template=email)
    2. Under if you like, choose a default template:, select Custom Text Template. You'll see the text template appear.
    3. Look for this block of code:
      {% for key,custom_field in custom_fields %}
      {% if not custom_field.is_hidden %}
      * {{ key|pad(20)|replace({'_': ' '})|title }} {{ custom_field.value }}
      {% endif %}
      {% endfor %}
      {% endif %} {# has custom fields #}
      {% endif %} {# not dunning reminder email #}
    4. Replace it with this block:
      <!-- start custom modifications -->
      {% for key,custom_field in custom_fields %}
      {% if key != "neighborhood" %}
      {% if not custom_field.is_hidden %}
      * {{ key|pad(20)|replace({'_': ' '})|title }} {{ custom_field.value }}
      {% endif %}
      {% endif %}
      {% endfor %}
      {% endif %} {# has custom fields #}
      {% endif %} {# not dunning reminder email #}
      <!-- end custom modifications -->
    5. Next, look for this line:
      {% include "address.email.inc.txt.twig" with {'address': billing_address} %}
    6. Replace it with this code:
      <!-- start custom modifications -->{% set show_address1 = true %}
      {% set show_address2 = true %}
      {% set show_city = true %}
      {% set show_region = true %}
      {% set show_postal_code = true %}
      {% set show_country = true %}
      {% if billing_address.type == 'billing' %}
      {%- if config.template_config.custom_checkout_field_requirements['billing_address1'] == 'hidden' -%}
      {%- set show_address1 = false -%}
      {%- endif %}
      {%- if config.template_config.custom_checkout_field_requirements['billing_address2'] == 'hidden' -%}
      {%- set show_address2 = false -%}
      {%- endif %}
      {%- if config.template_config.custom_checkout_field_requirements['billing_city'] == 'hidden' -%}
      {%- set show_city = false -%}
      {%- endif %}
      {%- if config.template_config.custom_checkout_field_requirements['billing_region'] == 'hidden' -%}
      {%- set show_region = false -%}
      {%- endif %}
      {%- if config.template_config.custom_checkout_field_requirements['billing_postal_code'] == 'hidden' -%}
      {%- set show_postal_code = false -%}
      {%- endif %}
      {%- if config.template_config.custom_checkout_field_requirements['billing_country'] == 'hidden' -%}
      {%- set show_country = false -%}
      {%- endif -%}
      {% endif %}
      {% if billing_address.first_name or billing_address.last_name %}
      {% if billing_address.first_name %}{{ billing_address.first_name }}{% endif %}{% if billing_address.last_name %} {{ billing_address.last_name }}
      {% endif %}
      {% endif %}
      {% if billing_address.company %}
      {{ billing_address.company }}
      {% endif %}
      {% if billing_address.tax_id and config.template_config.custom_checkout_field_requirements['billing_tax_id'] != 'hidden' %}
      {{ config.lang.checkout_tax_id }}: {{ address.tax_id }}
      {% endif %}
      {% if billing_address.address1 and show_address1 %}
      {{ billing_address.address1 }}
      {% endif %}
      {% if billing_address.address2 and show_address2 %}
      {{ billing_address.address2 }}
      {% endif %}
      {% if custom_fields|length > 0 %}
      {% for key,custom_field in custom_fields %}
      {% if key == "neighborhood" %}
      {% if not custom_field.is_hidden %}
      Barrio: {{ custom_field.value }}
      {% endif %}
      {% endif %}
      {% endfor %}
      {% endif %} {# has custom fields #}
      {% if billing_address.country_name == 'United States' %}
      {% if billing_address.city and show_city %}{{ billing_address.city }}{% endif %}{% if billing_address.region and show_region %}{% if billing_address.city and show_city %}, {% endif %}{{ billing_address.region }}{% endif %}{% if billing_address.postal_code and show_postal_code %} {{ billing_address.postal_code }}
      {% endif %}
      {% else %}
      {% if billing_address.city_and_region and show_city and show_region %}
      {{ billing_address.city_and_region }}
      {% elseif billing_address.city and show_city %}
      {{ billing_address.city }}
      {% elseif billing_address.region and show_region %}
      {{ billing_address.region }}
      {% endif %}
      {% if billing_address.postal_code and show_postal_code %}
      {{ billing_address.postal_code }}
      {% endif %}
      {% endif %}
      {% if billing_address.country_name and show_country %}
      {{ billing_address.country_name }}
      {% endif %}
      {% if geoip %}
      {{ geoip }}
      {% endif %}<!-- end custom modifications --><!-- {% include "address.email.inc.txt.twig" with {'address': billing_address} %} -->
    7. Scroll down and click Update Template to save.
    You can test an existing transaction (just make sure it's one of your tests so that your customer doesn't get an extra email) by clicking (email) under the customer name in the transactions history (https://admin.foxycart.com/admin.php?ThisAction=TransactionHistory)

    This will remove the neighborhood from the additional fields section and place it within the address.

    Hope that helps!
  • fc_marijafc_marija FoxyCart Team
    Hi @leaodonorte -

    I just realized that I used "Barrio" instead of "Bairro" for the neighborhood language! My apologies. You can go ahead and change that in the code that I shared.
Sign In or Register to comment.