php - 在 Weight WooCommerce 之前添加文本

标签 php wordpress woocommerce product hook-woocommerce

我正在使用 Woo Variations Table 插件,想在属性权重之前添加文本。有办法做到吗?我能够在价格之前添加标签文本,但在重量方面却没有运气。

// code
add_filter( 'woocommerce_get_price_html', 'cw_change_product_price_display' );
add_filter( 'woocommerce_cart_item_price', 'cw_change_product_price_display' );
function cw_change_product_price_display( $price ) {
    
    $text = __('TEXT');

    // returning the text before the price
    return $text . ' ' . $price;
}

最佳答案

add_filter( 'woocommerce_format_weight', 'woocommerce_format_weight', 10, 2 );

function woocommerce_format_weight( $weight_string, $weight ) {
    return __( "Weight Text", "woocommerce" ) . $weight_string;
}

关于php - 在 Weight WooCommerce 之前添加文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65786613/

相关文章:

php - 在数字字段中插入空值而不是 NULL

php - 在 PHP 和 Perl 之间传递大量数据

mysql - SQL查询按发布日期批量删除woocommerce产品

php - 电影院/电影院的调度系统 - 多个放映时间

php - S3 listObjectsV2 - StartAfter 未显示预期结果

wordpress - 忘记密码所需的 Woocommerce 简码

php - 在 WooCommerce 单一产品中显示产品属性列表的简码

php - 从所有 WooCommerce 预订中获取所有人的总和

php - 使用 CodeIgniter 查询 WordPress 博客

css - 移动设备的单列布局