Make a country-specific checkout notice

CliffSCliffS Member
We ship all over the globe, and notice that several countries have a consistently slow post.
We wish to warn our customers before they check out:


On the checkout page, look at the ship-to country, and have a notice above the checkout button:

// for shipments to Italy //
La spedizione in Italia potrebbe richiedere dai 20 ai 40 giorni.

// for shipments to Brazil //
O correio para o Brasil pode demorar de 20 a 40 dias.

... you get the idea.

Many thanks!
-Cliff

Comments
  • fc_adamfc_adam FoxyCart Team
    @CliffS,

    No problems, that's pretty straight forward to achieve. To have it appear just above the checkout complete button - you could include it as part of your custom checkout fields, as that's where they're included.

    You've already got some custom fields in the custom checkout fields configuration option - so you can simply include this below the code you've already got in the textarea and it'll appear between those fields and the checkout button:
    {% set shipping_message = "" %}

    {% if shipping_address.country == "IT" %}
    {% set shipping_message = "La spedizione in Italia potrebbe richiedere dai 20 ai 40 giorni." %}
    {% elseif shipping_address.country == "BR" %}
    {% set shipping_message = "O correio para o Brasil pode demorar de 20 a 40 dias." %}
    {% endif %}

    {% if shipping_message != "" %}
    <div class="fc-form-group ">
    <div class="col-md-8 col-md-offset-3">
    <div class="fc-input-group-container fc-input-group-container--checkbox fc-input-group-container--active">
    <div class="fc-form-group">
    {{ shipping_message }}
    </div>
    </div>
    </div>
    </div>
    {% endif %}
    That will handle outputting the message for Italy and Brazil - and you can expand on it to include additional conditions for other countries as needed. I hope that helps!
  • Many thanks Adam!

    I owe you yet another cup of West Coast Coffee!
  • Oops - one more thing (and another cup of coffee for you) ...

    It's first class package international service that's very slow.

    So how do I add if shipping method = "USPS First-Class Package International Service"

    which is to say, I'd like the line to work something like this:

    {% if shipping_address.country == "IT" AND ShippingMethod = "USPS First-Class Package International Service" %}

    rest of code...

    Thanks!
    -Cliff
  • fc_adamfc_adam FoxyCart Team
    edited February 6
    @CliffS,

    No problems! You would update that line to look like this:
    {% if shipping_address.country == "IT" and shipping_address.shipping_service_id == 39 %}
    That should detect if the customer has selected the First-Class Package International Service option.

    (Edit to correct case of the "and")
  • Adam, could you check the correctness of that line with the AND please?

    The following seems to cause an error for all customers:

    {% set shipping_message = "" %}

    {% if shipping_address.country == "IT" AND shipping_address.shipping_service_id == 39 %}
    {% set shipping_message = "La spedizione in Italia potrebbe richiedere dai 20 ai 40 giorni." %}
    {% elseif shipping_address.country == "BR" %}
    {% set shipping_message = "O correio para o Brasil pode demorar de 20 a 40 dias." %}
    {% endif %}

    {% if shipping_message != "" %}




    {{ shipping_message }}




    {% endif %}
  • fc_marijafc_marija FoxyCart Team
    Hi @CliffS -

    I think the issue is probably the "AND" in all caps. Once I changed it to lower case "and" on my tests, it worked. Let us know if you need anything else.
  • fc_adamfc_adam FoxyCart Team
    @CliffS,

    Ah sorry for the misdirection initially, @fc_marija is right there, it should be a lowercase and, rather than uppercase as it was in my earlier post. I've corrected my post for anyone else who might stumble upon this post later on. Again, sorry for providing the incorrect code previously!
Sign In or Register to comment.