-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Description
Prerequisites
- I have carried out troubleshooting steps and I believe I have found a bug.
- I have searched for similar bugs in both open and closed issues and cannot find a duplicate.
Describe the bug
I noticed that the Product Image Gallery block enqueues Photoswipe and filters woocommerce_single_product_zoom_enabled to be true
Expected behavior
Inside the render callback for the product gallery block and any other block where the product gallery is present, that filter should return true
Actual behavior
However, if adding content inside a block (such as custom product type displaying legacy content in the add to cart form block) this filter is not attached as the block is rendered before wp_enqueue_scripts has had a chance to run.
Steps to reproduce
A mve would be something like the following:
add_filter( 'render_block_woocommerce/add-to-cart-form', function( $content ) {
$test = apply_filters( 'woocommerce_single_product_photoswipe_enabled', get_theme_support( 'wc-product-gallery-lightbox' ) ) ? 'photoswipe enabled' : 'photoswipe disabled';
return '<p>' . $test . '</p>' . $content;
} );
When viewing a product with add to cart with options block (I think not the beta one, but that might have the same problem) the value of woocommerce_single_product_photoswipe_enabled is actually false
WordPress Environment
n/a
Isolating the problem
- I have deactivated other plugins and confirmed this bug occurs when only WooCommerce plugin is active.
- This bug happens with a default WordPress theme active, or Storefront.
- I can reproduce this bug consistently using the steps above.