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

Commit

Permalink
Return early if content retrieval fails
Browse files Browse the repository at this point in the history
  • Loading branch information
opr committed Nov 9, 2023
1 parent 88f044b commit 5f6eea9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Domain/Services/JetpackWooCommerceAnalytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,16 @@ public function get_cart_checkout_info() {
$checkout_template = get_block_template( $checkout_template_id );
}

// Something failed with the template retrieval, return early with 0 values rather than let a warning appear.
if ( ! $cart_template || ! $checkout_template ) {
return array(
'cart_page_contains_cart_block' => 0,
'cart_page_contains_cart_shortcode' => 0,
'checkout_page_contains_checkout_block' => 0,
'checkout_page_contains_checkout_shortcode' => 0,
);
}

// Update the info transient with data we got from the templates, if the site isn't using WC Blocks we
// won't be doing this so no concern about overwriting.
// Sites that load this code will be loading it on a page using the relevant block, but we still need to check
Expand Down

0 comments on commit 5f6eea9

Please sign in to comment.