• Resolved adscouk

    (@adscouk)


    I am getting the following error when checking out a product bundle or composite product in woocommerce:

    2020-09-29T12:45:04+00:00 CRITICAL Uncaught Error: Call to a member function appendChild() on null in /home/uktradeb/public_html/wp-content/plugins/woocommerce/vendor/pelago/emogrifier/src/Emogrifier.php:1165
    Stack trace:
    #0 /home/uktradeb/public_html/wp-content/plugins/woocommerce/vendor/pelago/emogrifier/src/Emogrifier.php(1021): Pelago\Emogrifier->addStyleElementToDocument(‘.bundled_table_…’)
    #1 /home/uktradeb/public_html/wp-content/plugins/woocommerce/vendor/pelago/emogrifier/src/Emogrifier.php(517): Pelago\Emogrifier->copyUninlinableCssToStyleNode(Array, ”)
    #2 /home/uktradeb/public_html/wp-content/plugins/woocommerce/vendor/pelago/emogrifier/src/Emogrifier.php(366): Pelago\Emogrifier->process()
    #3 /home/uktradeb/public_html/wp-content/plugins/woocommerce/includes/emails/class-wc-email.php(570): Pelago\Emogrifier->emogrify()
    #4 /home/uktradeb/public_html/wp-content/plugins/woocommerce/includes/emails/class-wc-email.php(650): WC_Email->style_inline(‘<h1 style=”text…’)
    #5 /home/uktradeb/public_html/wp-content/plugins/woocommerce/include in /home/uktradeb/public_html/wp-content/plugins/woocommerce/vendor/pelago/emogrifier/src/Emogrifier.php on line 1165

    I have managed to workaround this by changing line 1165 in Emogrifier.php from/to:

    // $headElement->appendChild($styleElement);
    if($headElement){$headElement->appendChild($styleElement);}

    The error occurs when creating the new order emails, which led me to think the emails had been customised, however they have not.

    Has anyone else had this error, as I don’t think I should have to change the Emogrifier.php as a workaround, as it will create problems down the line when it is updated?

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

    (@jessepearson)

    Automattic Happiness Engineer

    @adscouk You stated the error is happening when trying to check out with a bundle or composite in the cart, are you using the extensions sold at WooCommerce.com, or an extension from elsewhere? If the purchases were made through WooCommerce.com, you can submit a ticket through your account there in order to get the developers to take a look.

    If the extension is not from WooCommerce.com, it’s likely there are template modifications done in the extension that’s causing the error you’re seeing. If you check out with just a simple product in the cart, does the same issue happen? If not, then we would suggest reaching out to the developer of the extension you’re using for further assistance.

    Thread Starter adscouk

    (@adscouk)

    Thanks Jesse, yes it only happens on product bundles and composite products (I think it is to do with the indentation on the sub products).

    I purchased the extensions from woocommerce.com, so I’ll raise a ticket with them.

    Thanks again.

    SomewhereWarm

    (@somewherewarm)

    Hey all,

    The error indicates that the Emogrifier library could not find a HEAD element in your e-mail. This library is used by WooCommerce to inline CSS styles in e-mails, which ensures e-mails can be displayed correctly in different e-mail clients.

    Perhaps a plugin is loading its own (older?) version of Emogrifier?

    The reason this issue is “triggered” by Product Bundles and Composite Products probably has something to do with how Emogrifier tries to append CSS in the HEAD element, when a CSS selector can’t be recognized by Emogrifier. I can see that Emogrifier versions older than 3.0 did not recognize one of the child selectors used by PB/CP.

    @adscouk could you perhaps double check if the issue persists on a staging/test site

    – with all plugins disabled (except WooCommerce and Product Bundles or Composite Products) and
    – after switching your theme to a default WordPress or Storefront?

    Thanks!

    Cheers,
    Manos
    SomewhereWarm

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Woocommerce Emogrifier Error on Composite Products and Bundles’ is closed to new replies.