WooCommerce:在结帐字段更改输入类型

我的一位WooCommerce支持客户要求完成这项具有挑战性的任务(但最后很简单……!)。由于他们仅在美国进行贸易,因此他们希望在ZIP输入字段中强制使用“仅数字”,以便不允许使用字母。奇怪的WooCommerce并没有做到这一点!
仿牌独立站出海专家


// Change field type to number woocommerce checkout
 
function bbloomer_change_checkout_field_input_type() {
echo "<script>document.getElementById('billing_postcode').type = 'number';</script>";
}
  
add_action( 'woocommerce_after_checkout_form', 'bbloomer_change_checkout_field_input_type');