如何在cart.liquid文件中获取购物车的送货地址? [英] How can I get the cart's shipping address in the cart.liquid file?

查看:67
本文介绍了如何在cart.liquid文件中获取购物车的送货地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据用户当前的收货地址更改税金和收货方式提示.显然,他们尚未结帐,因此没有机会输入他们的送货地址.在此阶段,我还有什么可以检查的,以找出他们来自哪个国家/地区?

I'm trying to change the tax and shipping method prompt based on the user's current shipping address. Obviously, they are not yet at checkout so have not had the opportunity to input their shipping address. Is there anything else I can check at this stage to find out which country they are from?

{% if shipping_address.country_code = 'CA' %}
    <p class="cart-message meta">INCLUDING TAX AND SHIPPING (U.S. AND CANADA)</p>
{% else %}
    <p class="cart-message meta">{{ 'cart.general.tax_and_shipping' | t }} (INTERNATIONAL)</p>
{% endif %}

推荐答案

只有在访问者已经登录的情况下,才能访问cart.liquid的运输地址.否则,您可以使用第三方工具来显示特定于特定地点的特定div国家.

Shipping address at cart.liquid can only be accessed if visitor have already logged in. Else you can use third party tool to show a particular div specific to a particular country.

<script>
var txt = httpGet("https://ipapi.co/json/");
var obj = JSON.parse(txt);
var country = obj.country;

function httpGet(theUrl)
{
    var xmlHttp = new XMLHttpRequest();
    xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
    xmlHttp.send( null );
    return xmlHttp.responseText;
}
if(country == "CA"){
    // Show Div
}else{
  // Show Other Div
}        

</script>

注意:IP用于查找访问者的位置.

这篇关于如何在cart.liquid文件中获取购物车的送货地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆