PHP Warning: Attempt to read property “ID” on null

Hi,
i found this in the error_log:
PHP Warning: Attempt to read property “ID” on null in /home/oamjpugt/look4hair.com/wp-content/themes/pro/cornerstone/includes/integration/woocommerce.php on line 613

the line corresponds to this line of code:
: $post->ID;

which is contained within this function:
public function detect_layout_type( $type ) {
// WC Archive
if ( is_woocommerce() && $this->is_wc_archive() ) {
// Search for shop can be set to is_shop if post_type=product
// This checks that it is in fact the shop page not the another archive
if (is_search() && is_shop() && !apply_filters(“cs_wc_archive_overwrite_search”, false)) {
// Check current page
$urlPage = x_get_page_by_current_path();
$post = get_post();
// Top level id
$id = !empty($urlPage)
? $urlPage->ID
: $post->ID;
// If it’s a search this can also be an archive
$shop_id = wc_get_page_id (‘shop’);
// Shop is not the current page
// And it’s a search
if ( $id !== $shop_id) {
return $type;
}
}
// Normal assignments
return ‘layout:archive-wc’;
}
if ( is_woocommerce() || is_cart() || is_checkout() || is_account_page() ) {
return ‘layout:single-wc’;
}
return $type;
}

How can I solve it?
Thank you very much

Hello @scenaryo,

Thank you for your inquiry.

Would you mind telling us where this error occurs? We can’t reproduce the issue on our end. Please create a test page and provide the site URL in the secure note.

Best regards,
Ismael

Hi @Ismael,
frankly I don’t know where it occurred, I was reading the log files and I found this error… what could it depend on?

Hey @scenaryo,

You can ignore that PHP warning because it doesn’t affect any functionality but I have also reported this to our developer to fix the warning issue.

Thank you for pointing it out.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.