php - WooCommerce custom coupon discount -
i trying change default woocommerce coupon discount function adds discount price total cart price. instead of subtracting discount should add price.
i found done in includes/class-wc-cart.php
file, in function called: get_discounted_price
, woocommerce_get_discounted_price
i tried add filter accomplish above not working quite well:
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);
anyone can me out on this?
thanks
ok, thing works set negative coupon discount, -10:)
Comments
Post a Comment