我正在尝试显示来自 XX 的变体自定义价格跨度。
最低价格来自(多个)自定义字段值,我需要使用最低值。
最高价格应该是变化最高价格。
如果变体具有bulk_price
价值,我只想要这个,并且只在档案页面中显示它。我需要获取自定义字段值和最高价格。
这就是我所拥有的:
function change_product_price_display( $price) {
$bulk_price = get_post_meta([ 'variation_id' ], 'bulk_price', true);
$priceMax = $product->get_variation_price('max'); // Max price
//only show in archives
if (is_product_category()) {
//only if there is a bulk price
if ( $bulk_price ) {
return ' <span class="price-suffix">' . ' From ' . get_woocommerce_currency_symbol() .__( $bulk_price , "woocommerce") . ' - ' . $priceMax . '</span>';
}
}
//don't affect other products
else {
return $price;
}
}
add_filter( 'woocommerce_get_price_html', 'change_product_price_display');
add_filter( 'woocommerce_cart_item_price', 'change_product_price_display');
白板的微信