【发布时间】:2016-08-08 11:07:26
【问题描述】:
我正在尝试将默认 WooCommerce 优惠券折扣更改为将折扣价格添加到购物车总价格的功能。因此,与其减去折扣,不如将其加到价格中。
我发现这是在 includes/class-wc-cart.php 文件中的一个函数中完成的:get_discounted_price 和 woocommerce_get_discounted_price
我尝试添加一个过滤器来完成上述操作,但效果不佳:
function custom_discount($price) {
global $woocommerce;
$undiscounted_price = $price;
$product = $values['data'];
$discount_amount = $coupon->get_discount_amount( 'yes' === get_option( 'woocommerce_calc_discounts_sequentially', 'no' ) ? $price : $undiscounted_price, $values, true );
$discount_amount = min( $price, $discount_amount );
$price = max( $price + $discount_amount, 0 );
return $price;
}
add_filter( 'woocommerce_get_discounted_price', 'custom_discount', 10);
谁能帮我解决这个问题?
谢谢
【问题讨论】:
-
您是否搜索过有关增加费用而不是为此使用优惠券的信息?请告诉我,谢谢。
标签: php wordpress woocommerce coupon price