如何在WooCommerce购物车和结帐页面中添加后缀文本到价格?

时间:2017-05-10 09:31:11

标签: woocommerce suffix

我需要在购物车页面和结帐页面中显示价格(小计,总计...)之后添加文字提示。

我知道如何在单页和商店页面上执行此操作,但不知道在其他页面上执行此操作。我发现的唯一的东西就是这段代码,但它不起作用。

add_filter( 'woocommerce_get_price_html', 'custom_price_message' );
function custom_price_message( $price ) {
  $text = 'lorem';
  return $price . $text;
}

2 个答案:

答案 0 :(得分:2)

我找到了答案,但没有增加运费:

add_filter( 'woocommerce_cart_item_price', 'kd_custom_price_message' );
add_filter( 'woocommerce_cart_item_subtotal', 'kd_custom_price_message' );  
add_filter( 'woocommerce_cart_subtotal', 'kd_custom_price_message' );  
add_filter( 'woocommerce_cart_total', 'kd_custom_price_message' ); 

function kd_custom_price_message( $price ) {
    $afterPriceSymbol = ' TTC';
    return $price . $afterPriceSymbol;
}

答案 1 :(得分:0)

运费价格:

add_filter( 'woocommerce_cart_shipping_method_full_label', 'kd_custom_price_message' );
相关问题