I'm trying to show variation custom price-span from X-X.
- The lowest price comes from (multiple) custom field values, I need to use the lowest value.
- The highest price should be variation max price.
I only want this if the variation has the bulk_price
value, and only show it in archives pages. I need to get the custom field value, and the price max.
I'm working from:
"How can I get Min and Max price of a woocommerce variable product in Custom loop?"
and
"WooCommerce: Get custom field from product variations and display it as a suffix to variation prices"
This is what I have:
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');
$add_field
vs$bulk_price
. – 7uc1f3r