php - 带小数分隔符的 PHP 返回价格
问题描述
您能否帮助我了解如何自定义添加到 WordPress/Woocommerce 的以下代码的输出?我希望在千位之后用小数分隔符(点)分隔返回值(常规价格和销售价格),例如“1.200”。
编码:
function sr_change_variable_price($price, $product){
$html_tag = '<span id="reg_price">%s</span><span id="sale_price">%s</span>';
if($product->is_type('variable') AND !is_product()){
$test = $product->get_variation_regular_price('min') . ' Ft' ;
$min = $product->get_variation_sale_price('min') . ' Ft';
return(sprintf($html_tag, $test, $min));
}elseif($product->is_type('variable') AND is_product()){
return('');
}else
{return $price; // other cases
}
}
add_filter('woocommerce_get_price_html', 'sr_change_variable_price', 10, 2);
非常感谢您的帮助
解决方案
推荐阅读
- c++ - 结构内分配内存的 C++ 使用情况
- android - 如何更改 Vue PWA 中(Android)导航栏的颜色?
- excel - 在 Excel 中,有没有办法设置形状的默认透明度?
- android - PreferenceFragments 不在同一个 FragmentManager 中?
- ios - UISlider 的自定义拇指图像未显示完整的图像图标大小
- python - 在 python 中的网页抓取方面需要一些帮助
- node.js - 将从 pdfkit 生成的 PDF 作为输入提供给 pdf-lib 以进行合并
- android - 为什么 RoomDatabase.Callback 方法 onCreate 提供了 SupportSQLiteDatabase 参数?
- javascript - 无法实现 ValidatorFn 接口
- angular - 如何在构造函数中使用 Jasmine 私有 ActivatedRoute 进行测试?