我有这段代码可以用零或零价格替换所有产品的价格文本。我需要将代码修改为仅定位到simple_product
或custom_product_type
。
我在想类似的东西
if ( $product_type == 'simple' ) {
但是我不知道如何执行它。有任何建议。
add_filter( 'woocommerce_get_price_html', 'simple_price_free_zero_empty', 9999, 2 );
function simple_price_free_zero_empty( $price, $product ){
if ( '' === $product->get_price() || 0 == $product->get_price() ) {
$price = '<span class="woocommerce-Price-amount amount">NEW PRICE TEXT HERE</span>';
}
return $price;
}