Critical error on single product page

My website started showing this strange error recently which I have been unable to resolve. When I try to view a product, it returns a critical error.

I’ve done some troubleshooting and I realized the theme is the culprit. I have also checked the error log and I saw that this specific line of code is causing the error:

Uncaught Error: Call to a member function is_in_stock() on string in /home/u306409103/domains/apdbrestore.com/public_html/wp-content/themes/custom-theme/woocommerce/single-product.php:45 Stack trace: #0

When you check that line, it says:

<?php if( !$product->is_in_stock() ) : ?>
                <div class="outofstock">
                    <img src="<?php echo imgfolder('out-of-stock.png'); ?>" alt="Out of Stock">
                </div>
            <?php endif; ?>

To be specific the error is pointing towards the first line:

<?php if( !$product->is_in_stock() ) : ?>

I know the problem is coming from here but don’t know what next to do. What statement can I use here to do away with this error?

Thanks

The error means that $product contains a string, instead of an instance of a class, i.e. an object. You would need to determine why.

Sponsor our Newsletter | Privacy Policy | Terms of Service