diff --git a/modules/ppcp-compat/src/PPEC/SubscriptionsHandler.php b/modules/ppcp-compat/src/PPEC/SubscriptionsHandler.php index 79a67294e..90e2b5493 100644 --- a/modules/ppcp-compat/src/PPEC/SubscriptionsHandler.php +++ b/modules/ppcp-compat/src/PPEC/SubscriptionsHandler.php @@ -184,10 +184,12 @@ class SubscriptionsHandler { return true; } + // Are we editing an order or subscription tied to PPEC? // phpcs:ignore WordPress.Security.NonceVerification - $order_id = wc_clean( wp_unslash( $_GET['post'] ?? $_POST['post_ID'] ?? '' ) ); - if ( ! $order_id ) { - return false; + $order_id = wc_clean( wp_unslash( $_GET['id'] ?? $_GET['post'] ?? $_POST['post_ID'] ?? '' ) ); + if ( $order_id ) { + $order = wc_get_order( $order_id ); + return ( $order && PPECHelper::PPEC_GATEWAY_ID === $order->get_payment_method() ); } // Are we on the WC > Subscriptions screen? @@ -196,18 +198,15 @@ class SubscriptionsHandler { * * @psalm-suppress UndefinedClass */ - $post_type = class_exists( OrderUtil::class ) && OrderUtil::custom_orders_table_usage_is_enabled() - ? OrderUtil::get_order_type( $order_id ) ?? '' + $post_type_or_page = class_exists( OrderUtil::class ) && OrderUtil::custom_orders_table_usage_is_enabled() + // phpcs:ignore WordPress.Security.NonceVerification + ? wc_clean( wp_unslash( $_GET['page'] ?? '' ) ) // phpcs:ignore WordPress.Security.NonceVerification : wc_clean( wp_unslash( $_GET['post_type'] ?? $_POST['post_type'] ?? '' ) ); - if ( $post_type === 'shop_subscription' ) { + if ( $post_type_or_page === 'shop_subscription' || $post_type_or_page === 'wc-orders--shop_subscription' ) { return true; } - // Are we editing an order or subscription tied to PPEC? - // phpcs:ignore WordPress.Security.NonceVerification - $order = wc_get_order( $order_id ); - return ( $order && PPECHelper::PPEC_GATEWAY_ID === $order->get_payment_method() ); + return false; } - } diff --git a/modules/ppcp-wc-gateway/src/Gateway/OXXO/OXXO.php b/modules/ppcp-wc-gateway/src/Gateway/OXXO/OXXO.php index 171e51967..fc91f370e 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/OXXO/OXXO.php +++ b/modules/ppcp-wc-gateway/src/Gateway/OXXO/OXXO.php @@ -161,7 +161,7 @@ class OXXO { if ( $post_type === $screen ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended - $post_id = wc_clean( wp_unslash( $_GET['post'] ?? '' ) ); + $post_id = wc_clean( wp_unslash( $_GET['id'] ?? $_GET['post'] ?? '' ) ); $order = wc_get_order( $post_id ); if ( is_a( $order, WC_Order::class ) && $order->get_payment_method() === OXXOGateway::ID ) { $payer_action = $order->get_meta( 'ppcp_oxxo_payer_action' ); diff --git a/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php b/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php index 465240397..fc4dc8696 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php +++ b/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php @@ -519,7 +519,7 @@ class PayUponInvoice { if ( $post_type === $screen ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended - $post_id = wc_clean( wp_unslash( $_GET['post'] ?? '' ) ); + $post_id = wc_clean( wp_unslash( $_GET['id'] ?? $_GET['post'] ?? '' ) ); $order = wc_get_order( $post_id ); if ( is_a( $order, WC_Order::class ) && $order->get_payment_method() === PayUponInvoiceGateway::ID ) { $instructions = $order->get_meta( 'ppcp_ratepay_payment_instructions_payment_reference' );