【发布时间】:2020-04-20 11:23:04
【问题描述】:
这是我的 WordPress 配置(刚刚升级了一切,所以一切都是最新的):
WordPress:5.4
WooCommerce:4.0.1
Discount Rules for WooCommerce:1.9.7
WooCommerce 配置的折扣规则,每个数量块:
1-4 : 10%
5-24:20%
25-99999:30%
这在商店中运行得非常好,商店甚至可以通过折扣正确获得订单。 问题是我想删除 SALE!产品中的徽章,因为它是自动添加的,因为 1-4 数量块,这意味着根据配置默认 10% 的站点范围折扣。
现在,这是我在主题的 functions.php 中的代码
function wc_custom_replace_sale_text($html, $post, $product) {
if ($product->is_on_sale()) {
$regular_price = $product->get_regular_price();
$sale_price = $product->get_sale_price();
return '<span class="onsale force-display">' . $sale_price . '</span>';
}
}
add_filter( 'woocommerce_sale_flash', 'wc_custom_replace_sale_text', 10, 3 );
问题:无论我尝试什么,我总是得到$product->get_sale_price()结果总是0。而且,奇怪的是$product_is_on_sale()结果是true。
因此,我无法找到产品折扣,因此无法删除 1-4 数量块的 SALE 标签。
【问题讨论】:
-
我投票结束这个问题,因为这是一个错误,您应该在 Discount Rules for WooCommerce plugin support pages 上报告,因为 StackOverFlow 不处理任何软件支持。
-
现在可能有一种解决方法,因为该模块在各个方面都运行良好,我只是无法在挂钩中获得 $product->get_sale_price()。那么,可能有人可以建议其他一些功能吗?
-
我已经在WordPress插件页面本身提交了问题:wordpress.org/support/topic/…
标签: php wordpress woocommerce plugins discount