Skip to content

Instantly share code, notes, and snippets.

@xlplugins
Last active February 24, 2026 13:14
Show Gist options
  • Select an option

  • Save xlplugins/eacc53e7f07f0841d50ed9c86a2ecbc5 to your computer and use it in GitHub Desktop.

Select an option

Save xlplugins/eacc53e7f07f0841d50ed9c86a2ecbc5 to your computer and use it in GitHub Desktop.
FKCart + Discount Rules for WooCommerce - Coupon 0.00 Fix
if ( ! defined( 'ABSPATH' ) ) exit;
add_filter( 'woocommerce_coupon_discount_amount_html', function( $h, $c ) {
if ( ! $c || ! WC()->cart || (float) WC()->cart->get_coupon_discount_amount( $c->get_code(), WC()->cart->display_cart_ex_tax ) > 0 ) return $h;
$code = strtolower( $c->get_code() ); $m = \Wdr\App\Controllers\ManageDiscount::class;
$v = $m::$apply_as_coupon_values[ $code ]['value'] ?? null;
if ( $v === null ) foreach ( $m::$applied_cart_coupon_discounts ?? [] as $x ) { if ( strtolower( $x['name'] ?? '' ) === $code ) { $v = $x['value']; break; } }
if ( $v === null && count( WC()->cart->get_applied_coupons() ) === 1 ) {
$v = 0;
foreach ( WC()->cart->get_cart() as $k => $item ) {
$d = $m::$calculated_cart_item_discount[ $k ] ?? null;
if ( $d ) $v += ( (float)( $d['initial_price'] ?? 0 ) - (float)( $d['discounted_price'] ?? 0 ) ) * ( $item['quantity'] ?? 1 );
}
}
return ( class_exists( $m ) && $v > 0 ) ? wc_price( $v ) : $h;
}, 20, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment