更改WooCommerce权重字段接受字母

问题描述 投票:0回答:1

如何改变WooCommerce运输重量场接受字母,这样我就可以把值,如:

500克/ 1KG /750毫升/ 2L

是没有用的,除用于显示质量的重量,无需运费。

我已经通过了WooCommerce文件搜索,但我找不到在哪里它的设置。有人能指出我到控制这一领域的文件吗?

php html wordpress woocommerce
1个回答
0
投票

我已经解决了解决此问题。我简单地删除限制为重,包括字母,例如下面

//remove decimal only

add_action( 'wc_product_weight_enabled', 'remove_decimal_only' );

function remove_decimal_only() {
  woocommerce_wp_text_input( array( 'id' => '_weight', 'label' => __( 'Weight', 'woocommerce' ) . ' (' . get_option( 'woocommerce_weight_unit' ) . ')', 'placeholder' => wc_format_localized_decimal( 0 ), 'desc_tip' => 'true', 'description' => __( 'Enter weight including unit', 'woocommerce' ), 'type' => 'text' ) );

}

我不知道如何使用附加动作和过滤器最初,但现在他们是非常简单的。

该文件位于woocommerce /包括/管理/元盒/类-WC-元箱产品data.php

© www.soinside.com 2019 - 2024. All rights reserved.