From ae886ea425ededefcd30778421d991b5762bd6fc Mon Sep 17 00:00:00 2001 From: dinamiko Date: Tue, 4 Jan 2022 11:40:22 +0100 Subject: [PATCH] Fix psalm errors --- .../src/Helper/SubscriptionHelper.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/ppcp-subscription/src/Helper/SubscriptionHelper.php b/modules/ppcp-subscription/src/Helper/SubscriptionHelper.php index 1c99ca144..5a46d92ef 100644 --- a/modules/ppcp-subscription/src/Helper/SubscriptionHelper.php +++ b/modules/ppcp-subscription/src/Helper/SubscriptionHelper.php @@ -66,16 +66,20 @@ class SubscriptionHelper { } global $wp; - $order_id = (int) $wp->query_vars['order-pay'] ?? 0; + $order_id = (int) $wp->query_vars['order-pay']; if ( 0 === $order_id ) { return false; } $order = wc_get_order( $order_id ); - foreach ( $order->get_items() as $item ) { - $product = wc_get_product( $item->get_product_id() ); - if ( $product->get_type() === 'subscription' ) { - return true; + if ( is_a( $order, \WC_Order::class ) ) { + foreach ( $order->get_items() as $item ) { + if ( is_a( $item, \WC_Order_Item_Product::class ) ) { + $product = wc_get_product( $item->get_product_id() ); + if ( is_a( $product, \WC_Product_Subscription::class ) ) { + return true; + } + } } }