2016-08-08 47 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 :)