Home Forums WoodMart support forum AJAX Products tabs only current category

AJAX Products tabs only current category

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #700471

    dainius-4606
    Participant

    Hello,

    How can I get only current category in AJAX Products tabs without child categories? It shows with subcategories, I don’t need this. Screenshots attached.
    AJAX Products tabs is in front page.

    Attachments:
    You must be logged in to view attached files.
    #700547

    Hello,

    Currently, the Exclude option in the AJAX Products Tabs widget only allows you to exclude individual products by title or ID. It does not provide the ability to exclude entire subcategories, so all products from the current category and its child categories will still appear.

    You can use the Exclude field to remove specific products if needed, but excluding child categories is not available in this widget: https://ibb.co/bMPRZNLY

    Best Regards,

    #700674

    dainius-4606
    Participant

    Hello, maybe there is any function to exclude child categories?

    #700705

    Hello,

    Currently, the Exclude option in the AJAX Products Tabs widget only allows you to exclude individual products by title or ID. It does not provide the ability to exclude entire subcategories, so all products from the current category and its child categories will still appear.

    You can use the Exclude field to remove specific products if needed, but excluding child categories is not available in this widget: https://ibb.co/bMPRZNLY

    Best Regards,

    #700986

    dainius-4606
    Participant

    Hello,

    Maybe I can do like this function? But it doesn’t work with AJAX Products Tabs, I think there is some different query.

    add_action( ‘woocommerce_product_query’, ‘bbloomer_hide_products_subcategory’, 9999 );

    function bbloomer_hide_products_subcategory( $q ) {

    if ( ! is_product_category() ) return;

    $parent_id = get_queried_object_id();
    $subcats = woocommerce_get_product_subcategories( $parent_id );
    if ( empty( $subcats ) ) return;

    $tax_query = (array) $q->get( ‘tax_query’ );
    $tax_query[] = array(
    ‘taxonomy’ => ‘product_cat’,
    ‘field’ => ‘slug’,
    ‘terms’ => array_column( $subcats, ‘slug’ ),
    ‘operator’ => ‘NOT IN’
    );

    $q->set( ‘tax_query’, $tax_query, true );

    }

Viewing 5 posts - 1 through 5 (of 5 total)