0

是否可以在 woocommerce 结账时为移动用户激活数字键盘?

我已经自定义了 woocommerce 默认结帐字段,其中一些字段只是数字(例如:邮政编码、电话等)。

我的大多数网站访问者都是移动用户,我希望通过为这些输入字段激活数字小键盘来让他们更轻松地结帐。

我在网上搜索,我意识到如果您添加以下代码,将自动调用数字键盘。

<input inputmode="numeric" pattern="[0-9]*"> 

手指友好的数字输入inputmode

但我不知道如何将此属性添加到结帐字段,例如 billing_phone、billing_postcode 或其他要求输入号码的自定义字段。

任何帮助将不胜感激谢谢

4

1 回答 1

0

经过进一步研究,我从businessbloomer那里找到了这个问题的片段:

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

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

于 2020-07-11T19:44:04.677 回答