WooCommerce:在产品价格中添加前缀/后缀

有时您可能想在价格中添加前缀或后缀。可能是“ From…”,“ Only…”,“…taxtax free”等。
仿牌独立站出海专家

PHP代码段:在WooCommerce价格中添加后缀


add_filter( 'woocommerce_get_price_suffix', 'bbloomer_add_price_suffix', 99, 4 );
 
function bbloomer_add_price_suffix( $html, $product, $price, $qty ){
    $html .= ' suffix here';
    return $html;
}

PHP代码段:在WooCommerce价格中添加前缀


add_filter( 'woocommerce_get_price_html', 'bbloomer_add_price_prefix', 99, 2 );
 
function bbloomer_add_price_prefix( $price, $product ){
    $price = 'Prefix here ' . $price;
    return $price;
}