大数跨境

通过用户 IP ,判断网页是否在某个国家不显示

通过用户 IP ,判断网页是否在某个国家不显示 Shopify 主题开发
2026-07-16
2
导读:上代码。{% if section.settings.hide_section_by_country !
上代码。
{% if section.settings.hide_section_by_country != blank %}  <script>     document.addEventListener("DOMContentLoaded"function() {      fetch('https://ipapi.co/json/')        .then(response => response.json())        .then(data => {          console.log('pppppp-pp  ' + data)          if (data.country === 'DE') {            var targetSection = document.getElementsByClassName('hide-section-by-country');            if (targetSection.length > 0) {              targetSection[0].style.display = 'none';            }          }        })        .catch(error => console.log('Error fetching IP country:', error));  });  </script>{% endif %}
结束。

【声明】内容源于网络
0
0
Shopify 主题开发
分享独立站的实操经验与教训,也许对您运营 Shopify 有启发。阿飞,专注专研 Shopify 跨境电商方法。
内容 87
粉丝 0
Shopify 主题开发 分享独立站的实操经验与教训,也许对您运营 Shopify 有启发。阿飞,专注专研 Shopify 跨境电商方法。
总阅读14.0k
粉丝0
内容87