0

我需要指定默认的运输方式,因为在 Netsuite 的输入表单上没有提供任何信息。由于各种原因,我必须在 PDF/HTML 模板中执行此操作。这是我到目前为止的代码,但它似乎不起作用;

<#function toNumber val>
<#if val?has_content && val?length gt 0 >
<#return val?html?replace('[^0-9.]','','r')?number >
<#else><#return 0 ></#if></#function>

<#if record.shipmethod?has_content>

${record.shipmethod}  <!-- if a courier is selected -->

<#else>               <!-- else -->
<#list 2000..2560 as pcx>  <!-- Sydney Metro postcodes -->
<#if toNumber(record.shipzip)==pcx> 

Courier1              <!-- Standard Sydney Metro Courier -->

<#else>               <!-- else -->

Courier2              <!-- Standard Interstate Courier -->

</#if></#list></#if>
4

1 回答 1

1

您的循环每次运行时都会打印一些东西(即 560 行)!lte您应该使用(小于或等于)和gte(大于或等于)比较运算符来测试邮政编码是否在所需范围内,而不是循环遍历数字:

<#function toNumber val>
<#if val?has_content && val?length gt 0 >
<#return val?html?replace('[^0-9.]','','r')?number >
<#else><#return 0 ></#if></#function>

<#assign zip = toNumber(record.shipzip)>

<#if record.shipmethod?has_content>
  ${record.shipmethod}
<#elseif zip gte 2000 && zip lte 2560 >
  Courier 1
<#else>
  Courier 2
</#if>
于 2017-03-02T02:44:34.900 回答