2016-08-08 50 views
1

我正在尝试将默认WooCommerce优惠券折扣更改为其中的将折扣价格增加到总购物车价格的功能。所以不应该减去折扣,而应该把它加到价格上。WooCommerce自定义优惠券折扣

我发现,这是在includes/class-wc-cart.php文件来完成,在调用的函数:
get_discounted_pricewoocommerce_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); 

任何人都可以帮我解决这个问题吗?

感谢

+0

有你在身边寻找有关加费,而不是使用优惠券呢?请让我知道,谢谢。 – LoicTheAztec

回答

1

好吧,这工作的事情是设置一个负优惠券折扣,像-10 :)