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 <github-actions@github.com>
Co-authored-by: Barry Hughes <3594411+barryhughes@users.noreply.github.com>
This commit is contained in:
Narendra Sishodiya 2024-09-18 00:00:47 +05:30 committed by Christopher Allford
parent 04872e31f2
commit 1feb5af079
No known key found for this signature in database
GPG Key ID: 80E44C778F08A88E
2 changed files with 7 additions and 3 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Comment: Fixed call to a member function is_visible() on string | content-product.php:23

View File

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