Home Forums WoodMart support forum Frequently Bought Together causes fatal error if inserted into Elementor Popup

Frequently Bought Together causes fatal error if inserted into Elementor Popup

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #621168

    konsulenthusetprovi
    Participant

    Hey, I suspect this is just a regular ol’ Elementor bug.

    Seems like the FBT integration uses the global $product to fetch products, but this fails when editing a popup containing this element because… well, it’s a popup, not a product.

    Recreating the issue is quite simple:

    1) Create an Elementor Popup
    2) Insert the Frequently Bought Together element
    3) Save the popup.
    4) Try to access the popup editor again after navigating away.

    Here is the error log:

    [10-Dec-2024 10:14:39 UTC] PHP Fatal error: Uncaught Error: Call to a member function get_id() on null in /home/mrnykf/public_html/wp-content/themes/woodmart/inc/integrations/woocommerce/modules/frequently-bought-together/class-frontend.php:151
    Stack trace:
    #0 /home/mrnykf/public_html/wp-content/themes/woodmart/inc/modules/layouts/elementor/single-product/class-frequently-bought-together.php(290): XTS\Modules\Frequently_Bought_Together\Frontend->get_bought_together_products(Array)
    #1 /home/mrnykf/public_html/wp-content/plugins/elementor/includes/base/controls-stack.php(2325): XTS\Modules\Layouts\Frequently_Bought_Together->render()
    #2 /home/mrnykf/public_html/wp-content/plugins/elementor/includes/base/widget-base.php(635): Elementor\Controls_Stack->render_by_mode()
    #3 /home/mrnykf/public_html/wp-content/plugins/elementor/includes/base/widget-base.php(759): Elementor\Widget_Base->render_content()
    #4 /home/mrnykf/public_html/wp-content/plugins/elementor/includes/base/element-base.php(618): Elementor\Widget_Base->get_raw_data(true)
    #5 /home/mrnykf/public_html/wp-content/plugins/elementor/core/base/document.php(1084): Elementor\Element_Base->get_raw_data(true)
    #6 /home/mrnykf/public_html/wp-content/plugins/elementor-pro/modules/theme-builder/documents/theme-document.php(435): Elementor\Core\Base\Document->get_elements_raw_data(Array, true)
    #7 /home/mrnykf/public_html/wp-content/plugins/elementor/core/base/document.php(737): ElementorPro\Modules\ThemeBuilder\Documents\Theme_Document->get_elements_raw_data(NULL, true)
    #8 /home/mrnykf/public_html/wp-content/plugins/elementor/modules/library/documents/library-document.php(66): Elementor\Core\Base\Document->get_initial_config()
    #9 /home/mrnykf/public_html/wp-content/plugins/elementor-pro/modules/theme-builder/documents/theme-document.php(659): Elementor\Modules\Library\Documents\Library_Document->get_initial_config()
    #10 /home/mrnykf/public_html/wp-content/plugins/elementor-pro/modules/popup/document.php(81): ElementorPro\Modules\ThemeBuilder\Documents\Theme_Document->get_initial_config()
    #11 /home/mrnykf/public_html/wp-content/plugins/elementor/includes/base/controls-stack.php(1070): ElementorPro\Modules\Popup\Document->get_initial_config()
    #12 /home/mrnykf/public_html/wp-content/plugins/elementor/core/editor/loader/common/editor-common-scripts-settings.php(38): Elementor\Controls_Stack->get_config()
    #13 /home/mrnykf/public_html/wp-content/plugins/elementor/core/editor/loader/v2/editor-v2-loader.php(145): Elementor\Core\Editor\Loader\Common\Editor_Common_Scripts_Settings::get()
    #14 /home/mrnykf/public_html/wp-content/plugins/elementor/core/editor/editor.php(364): Elementor\Core\Editor\Loader\V2\Editor_V2_Loader->enqueue_scripts()
    #15 /home/mrnykf/public_html/wp-includes/class-wp-hook.php(324): Elementor\Core\Editor\Editor->enqueue_scripts(”)
    #16 /home/mrnykf/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(”, Array)
    #17 /home/mrnykf/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
    #18 /home/mrnykf/public_html/wp-includes/script-loader.php(2272): do_action(‘wp_enqueue_scri…’)
    #19 /home/mrnykf/public_html/wp-includes/class-wp-hook.php(324): wp_enqueue_scripts(”)
    #20 /home/mrnykf/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(”, Array)
    #21 /home/mrnykf/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
    #22 /home/mrnykf/public_html/wp-includes/general-template.php(3064): do_action(‘wp_head’)
    #23 /home/mrnykf/public_html/wp-content/plugins/elementor/includes/editor-templates/editor-wrapper.php(31): wp_head()
    #24 /home/mrnykf/public_html/wp-content/plugins/elementor/core/editor/loader/v2/editor-v2-loader.php(195): include(‘/home/mrnykf/pu…’)
    #25 /home/mrnykf/public_html/wp-content/plugins/elementor/core/editor/editor.php(169): Elementor\Core\Editor\Loader\V2\Editor_V2_Loader->print_root_template()
    #26 /home/mrnykf/public_html/wp-includes/class-wp-hook.php(324): Elementor\Core\Editor\Editor->init(”)
    #27 /home/mrnykf/public_html/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(”, Array)
    #28 /home/mrnykf/public_html/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
    #29 /home/mrnykf/public_html/wp-admin/admin.php(419): do_action(‘admin_action_el…’)
    #30 /home/mrnykf/public_html/wp-admin/post.php(12): require_once(‘/home/mrnykf/pu…’)
    #31 {main}
    thrown in /home/mrnykf/public_html/wp-content/themes/woodmart/inc/integrations/woocommerce/modules/frequently-bought-together/class-frontend.php on line 151

    #621193

    Artem Temos
    Keymaster

    Hello,

    Could you please record a short video so we can better understand how to reproduce the issue?

    Thank you in advance.

    #621205

    konsulenthusetprovi
    Participant

    Sure thing, see private information section here.

    #621222

    Artem Temos
    Keymaster

    This element works only on the single product page. It can’t be placed to a custom page.

    #621227

    konsulenthusetprovi
    Participant

    Ah okay, fair enough.

    Is there a different way to include the element in a popup?

    #621300

    Artem Temos
    Keymaster

    Unfortunately, this element is not designed to work inside the popup.

    #621302

    konsulenthusetprovi
    Participant

    I see – thank you for checking.

    Is there a way to modify the FBT element to include a HTML block?

    We can use a functions.php hook or something if that’s the easiest way to do it.

    #621448

    Artem Temos
    Keymaster

    Hello,

    You can try to do this by yourself but we don’t have instructions for such customizations. Find the code for this module here inc/integrations/woocommerce/modules/frequently-bought-together

    Kind Regards

    #621586

    konsulenthusetprovi
    Participant

    Hey,

    Thanks – we’ll give it a shot. Can we override this file in our child theme? Just so we don’t have to change it every time the theme updates 😉

    #621632

    Artem Temos
    Keymaster

    You can override only core WordPress template files like header.php, footer.php, index.php and others. Unfortunately, these files can’t be overridden.

Viewing 10 posts - 1 through 10 (of 10 total)