From 469b74433c4de51671d0c8690dd3b541bd9a32b6 Mon Sep 17 00:00:00 2001 From: Vlad Olaru Date: Fri, 12 Jan 2024 19:05:29 +0200 Subject: [PATCH] Fix Subscriptions autorenewals column for WooPayments pre-install promo in Settings > Payments (#43436) * Do not sanitize WooCommerce Subscriptiion column HTML in Settings > Payments methods table * Add features supports entry to pseudo-gateway WCPay Promotion * Add changelog * Add changelog entry for woocommerce-admin * Lint fixes --- ...t-settings-woopayments-promo-subscriptions | 4 +++ .../payment-promotion-row.tsx | 3 +- ...t-settings-woopayments-promo-subscriptions | 4 +++ ...PaymentGatewayPreInstallWCPayPromotion.php | 28 +++++++++++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 plugins/woocommerce-admin/changelog/fix-41476-payment-settings-woopayments-promo-subscriptions create mode 100644 plugins/woocommerce/changelog/fix-41476-payment-settings-woopayments-promo-subscriptions diff --git a/plugins/woocommerce-admin/changelog/fix-41476-payment-settings-woopayments-promo-subscriptions b/plugins/woocommerce-admin/changelog/fix-41476-payment-settings-woopayments-promo-subscriptions new file mode 100644 index 00000000000..42419101888 --- /dev/null +++ b/plugins/woocommerce-admin/changelog/fix-41476-payment-settings-woopayments-promo-subscriptions @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Do not sanitize HTML for WooCommerce Subscriptions column in Settings > Payments > Payment Methods table. diff --git a/plugins/woocommerce-admin/client/wp-admin-scripts/payment-method-promotions/payment-promotion-row.tsx b/plugins/woocommerce-admin/client/wp-admin-scripts/payment-method-promotions/payment-promotion-row.tsx index e6020069467..c35811a7ee1 100644 --- a/plugins/woocommerce-admin/client/wp-admin-scripts/payment-method-promotions/payment-promotion-row.tsx +++ b/plugins/woocommerce-admin/client/wp-admin-scripts/payment-method-promotions/payment-promotion-row.tsx @@ -194,7 +194,8 @@ export const PaymentPromotionRow: React.FC< PaymentPromotionRowProps > = ( { className={ column.className } width={ column.width } dangerouslySetInnerHTML={ - column.className.includes( 'sort' ) + column.className.includes( 'sort' ) || + column.className.includes( 'renewals' ) ? { __html: column.html, } diff --git a/plugins/woocommerce/changelog/fix-41476-payment-settings-woopayments-promo-subscriptions b/plugins/woocommerce/changelog/fix-41476-payment-settings-woopayments-promo-subscriptions new file mode 100644 index 00000000000..f1828f7a87a --- /dev/null +++ b/plugins/woocommerce/changelog/fix-41476-payment-settings-woopayments-promo-subscriptions @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +Add supports entry to pseudo-gateway for WooPayments pre-install promotion. diff --git a/plugins/woocommerce/src/Internal/Admin/WCPayPromotion/WCPaymentGatewayPreInstallWCPayPromotion.php b/plugins/woocommerce/src/Internal/Admin/WCPayPromotion/WCPaymentGatewayPreInstallWCPayPromotion.php index 7a14d002900..ba4946043a6 100644 --- a/plugins/woocommerce/src/Internal/Admin/WCPayPromotion/WCPaymentGatewayPreInstallWCPayPromotion.php +++ b/plugins/woocommerce/src/Internal/Admin/WCPayPromotion/WCPaymentGatewayPreInstallWCPayPromotion.php @@ -36,6 +36,34 @@ class WCPaymentGatewayPreInstallWCPayPromotion extends \WC_Payment_Gateway { $this->method_description = $wc_pay_spec->content; $this->has_fields = false; + // Set the promotion pseudo-gateway support features. + // If the promotion spec provides the supports property, use it. + if ( property_exists( $wc_pay_spec, 'supports' ) ) { + $this->supports = $wc_pay_spec->supports; + } else { + // Otherwise, use the default supported features in line with WooPayments ones. + // We include all features here, even if some of them are behind settings, since this is for info only. + $this->supports = array( + // Regular features. + 'products', + 'refunds', + // Subscriptions features. + 'subscriptions', + 'multiple_subscriptions', + 'subscription_cancellation', + 'subscription_reactivation', + 'subscription_suspension', + 'subscription_amount_changes', + 'subscription_date_changes', + 'subscription_payment_method_change_admin', + 'subscription_payment_method_change_customer', + 'subscription_payment_method_change', + // Saved cards features. + 'tokenization', + 'add_payment_method', + ); + } + // Get setting values. $this->enabled = false;