• Resolved cadmen99

    (@cadmen99)


    Hello,

    I have some other customizations on my woocommerce products for a specific category. Can anyone help me in finding the code that would remove the zoom feature from those pages only?

    I can maybe put the code inside an if is product category php statement but I dont know what code would go inside.

    Thank you in advanced

Viewing 1 replies (of 1 total)
  • Plugin Author Diana Burduja

    (@diana_burduja)

    Hello,

    you can add this PHP snippet to your child theme’s functions.php file to remove the zoom on the product pages for products in the “cat1” or “cat2” categories:

    add_action('wp_enqueue_scripts','remove_zoom_on_some_categories', 100);
    function remove_zoom_on_some_categories(){
        if ( !function_exists('is_product') ) return;
        if ( is_product() && has_term(array('cat1', 'cat2'), 'product_cat')) {
    	wp_dequeue_script('image_zoom-frontend');
        }
    }

    The PHP snippet will work only with product categories and not with the category parents. For example, if “cat1” category is child to the “cat-parent” category, then using the “cat-parent” in the script will not match the products from the “cat1” category.

    If you don’t feel comfortable adding the PHP snippet to the child theme’s functions.php file, then you can use a plugin similar to Code Snippets. The result will be the same.

Viewing 1 replies (of 1 total)
  • The topic ‘Disable zoom on specific category pages’ is closed to new replies.