【发布时间】:2022-01-09 19:02:46
【问题描述】:
我的子主题的functions.php文件中有以下代码,效果很好。
function themeprefix_custom_price_message( $price ) {
global $post;
$product_id = $post->ID;
$my_product_array = array( 270,373,378,506,1306,1311,1312,1444,1445,1447,1449,1930,1932,1933,1934,1935,1963,4146,4152,4153,4154 );//add in product IDs
if ( in_array( $product_id, $my_product_array )) {
$textafter = ' Each/Min 12'; //add your text
return $price . '<span class="price-description">' . $textafter . '</span>';
}
else
{
return $price;
}
}
add_filter( 'woocommerce_get_price_html', 'themeprefix_custom_price_message' );
但是,现在我需要添加另一组产品并在价格后启用不同的文本,即每个/分钟 8。我尝试了对上述内容的各种更改,并且每次都将网站关闭。如何调整上述内容以在价格后添加另一组(然后可能是另一组)具有不同文本的产品 ID?提前致谢!
【问题讨论】:
标签: php wordpress woocommerce