Update Jetpack WooCommerce Analytics module integration to check for changed template names (https://github.com/woocommerce/woocommerce-blocks/pull/11707)
This commit is contained in:
parent
41d40f47c2
commit
df27cbac96
|
@ -249,16 +249,16 @@ class JetpackWooCommerceAnalytics {
|
|||
$checkout_template = null;
|
||||
$cart_template_id = null;
|
||||
$checkout_template_id = null;
|
||||
$templates = $this->block_templates_controller->get_block_templates( array( 'cart', 'checkout' ) );
|
||||
$templates = $this->block_templates_controller->get_block_templates( array( 'cart', 'checkout', 'page-checkout', 'page-cart' ) );
|
||||
$guest_checkout = ucfirst( get_option( 'woocommerce_enable_guest_checkout', 'No' ) );
|
||||
$create_account = ucfirst( get_option( 'woocommerce_enable_signup_and_login_from_checkout', 'No' ) );
|
||||
|
||||
foreach ( $templates as $template ) {
|
||||
if ( 'cart' === $template->slug ) {
|
||||
if ( 'cart' === $template->slug || 'page-cart' === $template->slug ) {
|
||||
$cart_template_id = ( $template->id );
|
||||
continue;
|
||||
}
|
||||
if ( 'checkout' === $template->slug ) {
|
||||
if ( 'checkout' === $template->slug || 'page-checkout' === $template->slug ) {
|
||||
$checkout_template_id = ( $template->id );
|
||||
}
|
||||
}
|
||||
|
@ -274,6 +274,16 @@ class JetpackWooCommerceAnalytics {
|
|||
$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
|
||||
|
|
Loading…
Reference in New Issue