Use correct query arg when hpos is enabled

This commit is contained in:
Emili Castells Guasch 2023-08-02 15:52:26 +02:00
parent 5cd5a49016
commit 2cf7f23178
3 changed files with 12 additions and 13 deletions

View file

@ -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;
}
}

View file

@ -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' );

View file

@ -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' );