From 1feb5af0795ece2dbaabc7024756b55b1a35367c Mon Sep 17 00:00:00 2001 From: Narendra Sishodiya <32844880+narenin@users.noreply.github.com> Date: Wed, 18 Sep 2024 00:00:47 +0530 Subject: [PATCH] Fixed call to member function is_visible Fatal Error (#51286) * Fixed call to member function is_visible Fatal Error * Implemented the suggestions * Add changefile(s) from automation for the following project(s): woocommerce * Updated the @version tag * Promote 'comment' to actual changelog entry. * Add changefile(s) from automation for the following project(s): woocommerce --------- Co-authored-by: github-actions Co-authored-by: Barry Hughes <3594411+barryhughes@users.noreply.github.com> --- .../changelog/51286-51176-fixed-fatal-is_visible-func | 4 ++++ plugins/woocommerce/templates/content-product.php | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 plugins/woocommerce/changelog/51286-51176-fixed-fatal-is_visible-func diff --git a/plugins/woocommerce/changelog/51286-51176-fixed-fatal-is_visible-func b/plugins/woocommerce/changelog/51286-51176-fixed-fatal-is_visible-func new file mode 100644 index 00000000000..b604b3112e5 --- /dev/null +++ b/plugins/woocommerce/changelog/51286-51176-fixed-fatal-is_visible-func @@ -0,0 +1,4 @@ +Significance: patch +Type: fix +Comment: Fixed call to a member function is_visible() on string | content-product.php:23 + diff --git a/plugins/woocommerce/templates/content-product.php b/plugins/woocommerce/templates/content-product.php index 7423164e81c..b3bc12ad92c 100644 --- a/plugins/woocommerce/templates/content-product.php +++ b/plugins/woocommerce/templates/content-product.php @@ -12,15 +12,15 @@ * * @see https://woocommerce.com/document/template-structure/ * @package WooCommerce\Templates - * @version 3.6.0 + * @version 9.4.0 */ defined( 'ABSPATH' ) || exit; global $product; -// Ensure visibility. -if ( empty( $product ) || ! $product->is_visible() ) { +// Check if the product is a valid WooCommerce product and ensure its visibility before proceeding. +if ( ! is_a( $product, WC_Product::class ) || ! $product->is_visible() ) { return; } ?>