Hi, I'm trying to create a message to pop up in the shipping section of the checkout page when a specific country is selected.
I've followed the instructions listed on this site: https://help.shopify.com/en/manual/orders/status-tracking/customize-order-status/show-content-based-...
and below are my codes:
{% if checkout.shipping_address.country_code == 'FR' %}
<script type="text/javascript">
var customMessage = document.createElement("div");
customMessage.innerHTML = '<div class="section" style="padding-top: 3em"><div class="content-box"><div class="content-box__row"><p class="os-step__description">We're unable to ship to the following postal codes: Paris(postcode) 00000 ~ 00299, 00370~ 00449, 00500 ~ 00999. Please contact us for more info.</p></div></div></div>';
console.log(document.querySelector("[data-order-summary-section=payment-lines]"));
document.querySelector("[data-order-summary-section=payment-lines]").before(customMessage);
</script>
{% endif %}
Nothing shows up, and I'm not sure what went wrong. How can I fix this?
Thanks for post
checkout page customization allows only for Shopify plus plan do you have this?
no, sorry doesn't anther way
I am not very good but you can try this :
{% if checkout.shipping_address.country_code == 'FR' %}
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function(event) {
var customMessage = document.createElement("div");
customMessage.innerHTML = '<div class="section" style="padding-top: 3em"><div class="content-box">
<div class="content-box__row"><p class="os-step__description">We're unable to ship to the following postal codes: Paris(postcode) 00000 ~ 00299, 00370~ 00449, 00500 ~ 00999. Please contact us for more info.</p></div></div></div>';
console.log(document.querySelector(".address"));
document.querySelector(".address").after(customMessage);
alert(' We have a message !');
})
</script>
{% endif %}
User | Count |
---|---|
417 | |
209 | |
101 | |
89 | |
73 |