Skip to main content

Frequently Asked Questions

Comments

1 comment

  • Anuram

    Hi,

    Please add the below filter function in your child theme's functions.php file to achieve your requirement.

    add_filter('thwmsc_steps_front_end', 'thwmsc_remove_the_step_based_on_category');
    function thwmsc_remove_the_step_based_on_category($steps){
      $cat_in_cart = false;
      foreach ( WC()->cart->get_cart() as $item_key => $item_value ) {
        $_product = $item_value['data'];
      $cats = array('category_name1', 'category_name2');  // Category name

        if(has_term($cats, 'product_cat', $_product->get_id()) ) {
            $cat_in_cart = true;
            break;
        }
      }

      if($cat_in_cart){
      unset($steps['test_step']);   // New step name
        unset($steps['test_step1']);  // New step name
        unset($steps['test_step2']);  // New step name
      }

      return $steps;
    }

    In the above code snippet, please replace the following.

    1. The category_name1 and category_name2 with your corresponding category names.

    2. The test_step,test_step1, and test_step2 with the corresponding steps you would like to hide.

    I hope this will work for you.

    Have a great day! 

    0

Please sign in to leave a comment.

Powered by Zendesk