尝试显示有关电子邮件取消邮政编码的消息等于数组中的值
Trying to show a message on email cancelation if zip code eqauls a value within an array
如果在结帐页面上的订单中添加了特定的邮政编码,我将尝试显示条件消息。下面的代码,但当前不工作/
{% capture postcodes %}
3000|3122|3051
{% endcapture %}
{% assign postcode_array = postcodes | split: ' |' %}
{% for excludedPostcodes in postcode_array %}
{% assign postcode_vals = excludedPostcodes | split: '|' %}
{% if shipping_address.zip == postcode_vals %}
This is the postcode cancellation message
{% endif %}
{% endfor %}
你真的需要 {% assign postcode_vals = excludedPostcodes | split: '|' %}
行吗?
postcode_array
已经是一个数组,因此当您对其进行迭代时,您应该在(不幸命名的)excludedPostcodes
变量中获取单个元素。我觉得没必要再拆分了。
编辑:
还有这条线:
{% assign postcode_array = postcodes | split: ' |' %}
好像打错了,竖线前多了一个space
像这样的东西应该可以工作:
{% capture postcodes %}
3000|3122|3051
{% endcapture %}
{% assign postcode_array = postcodes | split: '|' %}
{% for post_code in postcode_array %}
{% if shipping_address.zip == post_code %}
This is the postcode cancellation message
{% endif %}
{% endfor %}
如果在结帐页面上的订单中添加了特定的邮政编码,我将尝试显示条件消息。下面的代码,但当前不工作/
{% capture postcodes %}
3000|3122|3051
{% endcapture %}
{% assign postcode_array = postcodes | split: ' |' %}
{% for excludedPostcodes in postcode_array %}
{% assign postcode_vals = excludedPostcodes | split: '|' %}
{% if shipping_address.zip == postcode_vals %}
This is the postcode cancellation message
{% endif %}
{% endfor %}
你真的需要 {% assign postcode_vals = excludedPostcodes | split: '|' %}
行吗?
postcode_array
已经是一个数组,因此当您对其进行迭代时,您应该在(不幸命名的)excludedPostcodes
变量中获取单个元素。我觉得没必要再拆分了。
编辑:
还有这条线:
{% assign postcode_array = postcodes | split: ' |' %}
好像打错了,竖线前多了一个space
像这样的东西应该可以工作:
{% capture postcodes %}
3000|3122|3051
{% endcapture %}
{% assign postcode_array = postcodes | split: '|' %}
{% for post_code in postcode_array %}
{% if shipping_address.zip == post_code %}
This is the postcode cancellation message
{% endif %}
{% endfor %}