Exclude Products From WooCommerce Fast Cart

WooCommerce Fast Cart is a handy plugin that optimizes the cart functionality on WooCommerce-powered websites. It allows customers to add products to their carts without leaving the current page, eliminating the need for constant redirects to the cart page. This feature significantly enhances user experience, making shopping more efficient and enjoyable.

Customizing WooCommerce Fast Cart

While WooCommerce Fast Cart enhances the shopping experience overall, there might be specific products or categories where you prefer not to enable this functionality. Fortunately, WooCommerce Fast Cart offers flexibility through customization options. One common customization is to exclude certain products or categories from utilizing the fast cart feature.

Excluding Products from Fast Cart

To exclude specific products or categories from using the fast cart functionality, you can utilize a simple code snippet. Below is an example of how to achieve this using WordPress filters:

add_filter( 'wfc_enabled_on_page', 'my_wfc_enabled_on_page' );

function my_wfc_enabled_on_page( $var ) {
if ( class_exists( 'WooCommerce' ) ) {
global $post;

$post_id = $post->ID;

$specific_product_ids = array( 3683, 2, 3 ); // Replace with your product IDs

$specific_category_ids = array( 23, 5 ); // Replace with your category IDs

if ( is_product() && in_array( $post_id, $specific_product_ids ) ) {
$var = false;
} elseif ( has_term( $specific_category_ids, 'product_cat', $post_id ) ) {
$var = false;
}
}

return $var;
}

How to Implement the Code

You can add this code snippet to your WordPress site using a child theme’s functions.php file or by utilizing a code snippets plugin. Here’s a brief guide on how to do it:

By implementing this code snippet, you can effectively exclude specific products or categories from utilizing the WooCommerce Fast Cart functionality, ensuring a tailored shopping experience for your customers.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top