如何解决在商店页面中显示最大可变价格 - Woocommerce
我有这个代码来显示价格。
function edit_selected_variation_price( $data,$product,$variation ) {
$price = $variation->price;
$price_incl_tax = $price + round($price * ( 23 / 100 ),2);
$price_incl_tax = number_format($price_incl_tax,2,",".");
$price = number_format($price,".");
$display_price = '<div><span class="price">';
$display_price .= '<span>Cena netto</span><span class="amount">' . $price .'<small class="woocommerce-price-suffix"> zł</small></span>';
$display_price .= '</div><div>';
$display_price .= '<span>Cena brutto</span><span class="amount">' . $price_incl_tax .'<small class="woocommerce-price-suffix"> zł</small></span>';
$display_price .= '</span></div>';
$data['price_html'] = $display_price;
return $data;
}
add_filter( 'woocommerce_available_variation','edit_selected_variation_price',10,3);
如何在不选择任何款式的情况下显示最高价格?
解决方法
我不完全理解你的问题,你想要什么价格的最高价格(含税和......)?
但是,当数组中有不同的价格(或作为松散变量)时,请考虑使用 PHP max()
函数:
https://www.php.net/manual/en/function.max.php
这将返回最高值(希望这就是您所追求的)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。