{"id":18755975,"date":"2025-12-15T05:28:39","date_gmt":"2025-12-15T05:28:39","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/fatal-php-error-45\/"},"modified":"2025-12-15T05:28:39","modified_gmt":"2025-12-15T05:28:39","slug":"fatal-php-error-45","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/fatal-php-error-45\/","title":{"rendered":"fatal PHP error"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>Hello,<br \/>I am experiencing a fatal PHP error caused by the plugin ACO Product Labels for WooCommerce.<br \/><br \/>Error details:<br \/><br \/>Uncaught Error: Call to a member function get_ID() on null<br \/>File: \/includes\/class-acoplw-badge.php<br \/>Line: 144<br \/><br \/>This happens when the badge is rendered outside of a standard WooCommerce product context (for example inside Porto \/ Elementor posts grid or during REST API calls). In these cases, the $product object is null, but the plugin still calls $product-&gt;get_ID() without checking if the product exists.<br \/><br \/>Stack trace clearly shows the badge being triggered via acoplwBadgeHook in non-product contexts.<br \/><br \/>It looks like a missing safety check before calling get_ID(). A simple guard such as:<br \/><br \/>if ( ! is_object( $product ) || ! method_exists( $product, 'get_ID' ) ) {<br \/>return '';<br \/>}<br \/><br \/>would prevent the fatal error.<br \/><br \/>At the moment the only workaround is disabling the plugin or limiting the badge usage, otherwise the site crashes.<br \/><br \/>Could you please confirm if this is a known issue and if a fix is planned?<br \/><br \/>Thank you for your support.<\/code><\/pre>\n","protected":false},"template":"","class_list":["post-18755975","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/18755975","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/18755975\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=18755975"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}