SOLVED: Woocommerce Shortcode Error

Bricks Version: 1.1.3
Browser: Chrome 90
OS: macOS / Windows / Linux / etc.
URL: (a link to a page that illustrates the issue would be really helpful)

[Please describe in as much detail as possible how we can replicate this bug]

If you use the woocommerce shortcode [product_page id=“ID”] on a page that is not a single product the image gallery does not work.

Error in console:
Uncaught TypeError: Cannot read property ‘firstChild’ of undefined
at Object.getChildByClass (bricks.min.js?ver=1629883322:1)
at Object.init (bricks.min.js?ver=1629883322:1)
at e.openPhotoswipe (single-product.min.js?ver=5.6.0:1)
at HTMLDivElement.dispatch (jquery.min.js?ver=3.6.0:2)
at HTMLDivElement.v.handle (jquery.min.js?ver=3.6.0:2)

Hello @draison

Welcome to the Bricks forum and thank you for your report.

It is very difficult for Bricks to know about this shortcode and enqueue the needed scripts if the shortcode is used outside the product template. My suggestion is that you enqueue the needed scripts using your child theme functions.php.

Example:

<?php 
function add_theme_scripts() {
    wp_enqueue_script( 'wc-single-product' );
}
add_action( 'wp_enqueue_scripts', 'add_theme_scripts' );
1 Like

Thank you. I know it’s hard but thanks for the tip.
Have a nice day.

1 Like