Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Miguel Carneiro

    (@pixelhunter)

    upgrade your plugin and now works fine .

    thanks for your work 🙂

    Thread Starter Miguel Carneiro

    (@pixelhunter)

    The error occurs only when we edit a custom template or single product template

    if u need more details please share

    thanks 🙂

    Thread Starter Miguel Carneiro

    (@pixelhunter)

    hello friend

    you can tru breakdance page builder here: https://breakdance.com/try/

    I change this for teste proposes and works very good

    When using the “video-wc-gallery” plugin alongside the Breakdance page builder, the following fatal error occurs:

    Fatal error: Uncaught Error: Call to a member function is_type() on string 
    in /wp-content/plugins/video-wc-gallery/functions/do.php on line 337
    

    Root Cause

    In the vwg_add_custom_style_and_scripts_product_page() function (functions/do.php, line 337), the code attempts to call:

    $product->is_type('variable');
    

    However, when used with the Breakdance page builder, the global $product variable is sometimes initialized as a string instead of a WooCommerce product object, leading to the fatal error.Solution

    To ensure compatibility with Breakdance and other page builders that may alter the WooCommerce product object initialization, implement the following fix:

    function vwg_add_custom_style_and_scripts_product_page() {
        if (is_product()) {
            global $product;
    
            // Ensure $product is a valid object and initialize if necessary
            if (!is_object($product)) {
                $product = wc_get_product(get_the_ID());
            }
    
            // Verify that we now have a valid product object
            if (!is_object($product)) {
                return; // Exit the function if $product is still not valid
            }
    
            // Continue with the rest of the function...
        }
    }
    

    Summary

    This fix provides a fallback mechanism to correctly initialize the $product object, preventing fatal errors and improving compatibility with Breakdance and similar page builders.


Viewing 3 replies - 1 through 3 (of 3 total)