Created
May 25, 2026 11:32
-
-
Save xlplugins/43fa3c676162c3bcf682c18c0275d4c8 to your computer and use it in GitHub Desktop.
coupon discount inside the FunnelKit sliding cart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Show the cumulative coupon discount inside the FunnelKit sliding cart, | |
| * just above the checkout button. | |
| */ | |
| add_action( 'fkcart_before_checkout_button', 'betterwood_fkcart_discount_anzeigen' ); | |
| function betterwood_fkcart_discount_anzeigen() { | |
| if ( is_null( WC()->cart ) || WC()->cart->is_empty() ) { | |
| return; | |
| } | |
| WC()->cart->calculate_totals(); | |
| $coupon_discount_totals = WC()->cart->coupon_discount_totals; | |
| $coupon_discount_tax_totals = WC()->cart->coupon_discount_tax_totals; | |
| $coupon_discount_totals_value = 0.0; | |
| $coupon_discount_totals_tax_value = 0.0; | |
| foreach ( $coupon_discount_totals as $value ) { | |
| $coupon_discount_totals_value += $value; | |
| } | |
| foreach ( $coupon_discount_tax_totals as $value ) { | |
| $coupon_discount_totals_tax_value += $value; | |
| } | |
| $discount_subtotal_price = WC()->cart->get_subtotal() + WC()->cart->get_subtotal_tax(); | |
| $discount_total_price = $coupon_discount_totals_value + $coupon_discount_totals_tax_value; | |
| if ( $discount_subtotal_price > 0 ) { | |
| $percentage_price = ( 100 * $discount_total_price ) / $discount_subtotal_price; | |
| } else { | |
| $percentage_price = 0; | |
| } | |
| if ( $discount_total_price <= 0.0 ) { | |
| return; | |
| } | |
| ?> | |
| <div class="fkcart-mengenrabatt-row" style="display:flex; justify-content:space-between; align-items:center; padding:8px 16px; font-size:14px;"> | |
| <span><?php echo number_format( $percentage_price, 0 ); ?>% <?php esc_html_e( 'Mengenrabatt', 'woocommerce' ); ?></span> | |
| <span class="woocommerce-Price-amount amount"> | |
| -<?php echo number_format( $discount_total_price, 2, ',', '.' ); ?> | |
| <span class="woocommerce-Price-currencySymbol">€</span> | |
| </span> | |
| </div> | |
| <?php | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment