From e66ccf698c073f438342462ca4c06dcb58095e61 Mon Sep 17 00:00:00 2001 From: Seghir Nadir Date: Fri, 23 Aug 2024 17:34:57 +0200 Subject: [PATCH] Run Checkout block coupon filter on empty array (#50876) * Run Checkout block coupon filter on empty array * fix conditional * Add changefile(s) from automation for the following project(s): woocommerce-blocks * remove useless eslint skip --------- Co-authored-by: github-actions --- .../cart-checkout/totals/discount/index.tsx | 14 +++++++------- .../changelog/50876-fix-run-coupon-filter-on-empty | 4 ++++ 2 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 plugins/woocommerce/changelog/50876-fix-run-coupon-filter-on-empty diff --git a/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/discount/index.tsx b/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/discount/index.tsx index 972708fcfcb..bcf886113a8 100644 --- a/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/discount/index.tsx +++ b/plugins/woocommerce-blocks/assets/js/base/components/cart-checkout/totals/discount/index.tsx @@ -49,7 +49,13 @@ const TotalsDiscount = ( { } = values; const discountValue = parseInt( totalDiscount, 10 ); - if ( ! discountValue && cartCoupons.length === 0 ) { + const filteredCartCoupons = applyCheckoutFilter( { + arg: filteredCartCouponsFilterArg, + filterName: 'coupons', + defaultValue: cartCoupons, + } ); + + if ( ! discountValue && filteredCartCoupons.length === 0 ) { return null; } @@ -61,12 +67,6 @@ const TotalsDiscount = ( { ? discountValue + discountTaxValue : discountValue; - const filteredCartCoupons = applyCheckoutFilter( { - arg: filteredCartCouponsFilterArg, - filterName: 'coupons', - defaultValue: cartCoupons, - } ); - return (