Skip to content

Commit

Permalink
Enqueue wc-cart-fragments always, remove limit (#2116)
Browse files Browse the repository at this point in the history
* Enqueue wc-cart-fragments always, remove limit

* Remove the unused limit_cart_sync_to_wc_pages function
  • Loading branch information
albarin authored Aug 11, 2023
1 parent af6f343 commit 9b7bd43
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions inc/class-storefront.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public function __construct() {
add_filter( 'wp_page_menu_args', array( $this, 'page_menu_args' ) );
add_filter( 'navigation_markup_template', array( $this, 'navigation_markup_template' ) );
add_action( 'enqueue_embed_scripts', array( $this, 'print_embed_styles' ) );
add_filter( 'woocommerce_get_script_data', array( $this, 'limit_cart_sync_to_wc_pages' ), 10, 2 );
}

/**
Expand Down Expand Up @@ -377,24 +376,6 @@ public function scripts() {
}
}

/**
* Limit Cart Sync functionality to specific WooCommerce pages or when the Widget Cart is active.
* More details: https://developer.woocommerce.com/2023/06/16/best-practices-for-the-use-of-the-cart-fragments-api/
*
* @param string $script_data The script data.
* @param string $handle The script handle.
* @return string|null
*/
public function limit_cart_sync_to_wc_pages( $script_data, $handle ) {
if ( 'wc-cart-fragments' === $handle ) {
if ( is_woocommerce() || is_cart() || is_checkout() || is_active_widget( false, false, 'woocommerce_widget_cart', true ) ) {
return $script_data;
}
return null;
}
return $script_data;
}

/**
* Register Google fonts.
*
Expand Down

0 comments on commit 9b7bd43

Please sign in to comment.