Uncaught Error: Call to a member function get_type() on bool - BackinStock Notifier Wordpress Plugin
Zaw Htut Win
Posted on January 12, 2024
It's because of the following code, the error was being thrown.
/plugins/backinstocknotifier/backinstocknotifier.php
$product = wc_get_product($post_id);
if($product->get_type() == 'variable') {
// the rest of the code
}
It doesn't check the post is the product or not, so when the post is not the product, the plugin will throw error.
So we can correct the code such as,
$product = wc_get_product($post_id);
if(isset($product) && $product === false){return;} // exit the function if the post_id not corresponding to product
if($product->get_type() == 'variable') {
// the rest of the code
}
💖 💪 🙅 🚩
Zaw Htut Win
Posted on January 12, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.