Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Load required scripts in LegacyTemplate.php render method (#5346)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjcafferkey committed Dec 22, 2021
1 parent 987b6d6 commit a6803cf
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/BlockTypes/LegacyTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ protected function render( $attributes, $content ) {
return;
}

// We need to load the scripts here because when using block templates wp_head() gets run after the block template.
// As a result we are trying to enqueue required scripts before we have even registered them.
// See here for more information: https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues/5328#issuecomment-989013447.
if ( class_exists( 'WC_Frontend_Scripts' ) ) {
$frontend_scripts = new \WC_Frontend_Scripts();
$frontend_scripts::load_scripts();
}

$archive_templates = array( 'archive-product', 'taxonomy-product_cat', 'taxonomy-product_tag' );

if ( 'single-product' === $attributes['template'] ) {
Expand Down

0 comments on commit a6803cf

Please sign in to comment.